Class: Railslog::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/railslog.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry_text) ⇒ Entry

Returns a new instance of Entry.



78
79
80
81
# File 'lib/railslog.rb', line 78

def initialize(entry_text)
  @text = Helper.normalize(entry_text)
  @author = parse_author(entry_text)
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



72
73
74
# File 'lib/railslog.rb', line 72

def author
  @author
end

#textObject (readonly)

Returns the value of attribute text.



72
73
74
# File 'lib/railslog.rb', line 72

def text
  @text
end

Class Method Details

.recognize?(line) ⇒ Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/railslog.rb', line 74

def self.recognize?(line)
  line =~ /^\*\s+/
end

Instance Method Details

#add_line(text) ⇒ Object



83
84
85
86
87
# File 'lib/railslog.rb', line 83

def add_line(text)
  text.gsub!(/[\r\n]/, '')
  @text << "\n#{text}"
  @author = parse_author(text) || @author
end

#to_sObject



89
90
91
# File 'lib/railslog.rb', line 89

def to_s
  "<#{self.class} author:#{@author} text:#{truncated_text}>"
end