class Notes::Task

Attributes

author[RW]
context[RW]
date[RW]
filename[RW]
flags[RW]
line[RW]
line_num[RW]

Public Class Methods

new(options={}) click to toggle source
# File lib/notes-cli/tasks.rb, line 7
def initialize(options={})
  @author   = options[:author]
  @date     = options[:date]
  @sha      = options[:sha]
  @filename = options[:filename]
  @line_num = options[:line_num]
  @line     = options[:line]
  @flags    = options[:flags]
  @context  = options[:context]
end

Public Instance Methods

to_json() click to toggle source
# File lib/notes-cli/tasks.rb, line 32
def to_json
  {
   filename: @filename,
   line_num: @line_num,
   line:     @line,
   flags:    @flags,
   context:  @context,
   author:   @author,
   date:     @date,
   sha:      @sha
  }
end
to_s() click to toggle source

Return a String in a format suitable for printing to the console that includes the line number and matched flag highlighted in color

TODO: different colors for different flags

# File lib/notes-cli/tasks.rb, line 23
def to_s
  flag_regex = Regexp.new(@flags.join('|'), true)
  line  = @line.gsub(flag_regex) do |flag|
    Notes.colorize('yellow', flag)
  end

  "ln #{@line_num}: #{line.strip}"
end