class Worklog::LogEntry
@return [String] the project associated with the log entry.
@!attribute [rw] project
@return [String] the message of the log entry.
@!attribute [rw] message
@return [Boolean] whether the log entry is an epic.
@!attribute [rw] epic
@return [String] the URL associated with the log entry.
@!attribute [rw] url
@return [String] the ticket associated with the log entry.
@!attribute [rw] ticket
@return [Array<String>] the tags associated with the log entry.
@!attribute [rw] tags
@return [DateTime] the date and time of the log entry.
@!attribute [rw] time
@see DailyLog
A single log entry in a DailyLog.
def self.from_hash(hash)
-
(LogEntry)
- the created LogEntry object
Parameters:
-
hash
(Hash
) -- the hash to convert
def self.from_hash(hash) new( time: hash[:time], tags: hash[:tags], ticket: hash[:ticket], url: hash[:url], epic: hash[:epic], message: hash[:message], project: hash[:project] ) end
def ==(other)
-
(Boolean)
- True if the log entries are equal, false otherwise.
Parameters:
-
other
(LogEntry
) -- The other log entry to compare against.
def ==(other) time == other.time && tags == other.tags && ticket == other.ticket && url == other.url && epic == other.epic && message == other.message end
def epic?
-
(Boolean)
-
def epic? @epic == true end
def initialize(params = {})
def initialize(params = {}) @time = params[:time] # If tags are nil, set to empty array. # This is similar to the CLI default value. @tags = params[:tags] || [] @ticket = params[:ticket] @url = params[:url] || '' @epic = params[:epic] @message = params[:message] @project = params[:project] # Back reference to the day @day = params[:day] || nil end
def message_string(known_people = nil)
-
known_people
() -- Hash[String, Person] A hash of people with their handles as keys.
def message_string(known_people = nil) # replace all mentions of people with their names. msg = @message.dup people.each do |person| next unless known_people && known_people[person] msg.gsub!(/[~@]#{person}/) do |match| s = '' s += ' ' if match[0] == ' ' s += "#{Rainbow(known_people[person].name).underline} (~#{person})" if known_people && known_people[person] s end end s = '' s += if epic Rainbow("[EPIC] #{msg}").bg(:white).fg(:black) else msg end s += " [#{Rainbow(@ticket).fg(:blue)}]" if @ticket # Add tags in brackets if defined. s += ' [' + @tags.map { |tag| "#{tag}" }.join(', ') + ']' if @tags && @tags.size > 0 # Add URL in brackets if defined. s += " [#{@url}]" if @url && @url != '' s += " [#{@project}]" if @project && @project != '' s end
def people
def people # Return people that are mentioned in the entry. People are defined as character sequences # starting with @ or ~. Whitespaces are used to separate people. Punctuation is ignored. # Empty set if no people are mentioned. # @return [Set<String>] @message.scan(PERSON_REGEX).flatten.uniq.sort.to_set end
def people?
-
(Boolean)
-
def people? people.size.positive? end
def to_yaml
def to_yaml to_hash.to_yaml end