Class: PoParser::Comment
- Inherits:
-
Object
- Object
- PoParser::Comment
- Defined in:
- lib/poparser/comment.rb
Instance Attribute Summary collapse
-
#str ⇒ Object
Returns the value of attribute str.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type, str) ⇒ Comment
constructor
A new instance of Comment.
- #to_s(with_label = false) ⇒ Object
- #to_str ⇒ Object
Constructor Details
#initialize(type, str) ⇒ Comment
Returns a new instance of Comment.
5 6 7 8 |
# File 'lib/poparser/comment.rb', line 5 def initialize(type, str) @type = type @str = str end |
Instance Attribute Details
#str ⇒ Object
Returns the value of attribute str.
3 4 5 |
# File 'lib/poparser/comment.rb', line 3 def str @str end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/poparser/comment.rb', line 3 def type @type end |
Instance Method Details
#to_s(with_label = false) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/poparser/comment.rb', line 10 def to_s(with_label = false) return @str unless with_label if @str.is_a? Array string = [] @str.each do |str| string << "#{COMMENTS_LABELS[@type]} #{str}\n".gsub(/[^\S\n]+$/, '') end return string.join else # removes the space but not newline at the end "#{COMMENTS_LABELS[@type]} #{@str}\n".gsub(/[^\S\n]+$/, '') end end |
#to_str ⇒ Object
24 25 26 |
# File 'lib/poparser/comment.rb', line 24 def to_str @str end |