Class: Comment
- Inherits:
-
Object
- Object
- Comment
- Defined in:
- lib/mark_set_go/comment.rb
Instance Attribute Summary collapse
-
#lines ⇒ Object
Returns the value of attribute lines.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(init_line) ⇒ Comment
constructor
A new instance of Comment.
- #remove_comment(line) ⇒ Object
- #set_type ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(init_line) ⇒ Comment
Returns a new instance of Comment.
4 5 6 7 |
# File 'lib/mark_set_go/comment.rb', line 4 def initialize(init_line) @lines = [init_line] set_type end |
Instance Attribute Details
#lines ⇒ Object
Returns the value of attribute lines.
2 3 4 |
# File 'lib/mark_set_go/comment.rb', line 2 def lines @lines end |
#type ⇒ Object
Returns the value of attribute type.
2 3 4 |
# File 'lib/mark_set_go/comment.rb', line 2 def type @type end |
Instance Method Details
#remove_comment(line) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/mark_set_go/comment.rb', line 17 def remove_comment(line) if /^\/\//.match(line) line.gsub(/^\/\//, '') elsif /^\/\*/.match(line) line.gsub(/^\/\*/, '') else line end end |
#set_type ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/mark_set_go/comment.rb', line 9 def set_type if @lines.first.start_with? "/*" @type = "block" else @type = "line" end end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/mark_set_go/comment.rb', line 27 def to_s @lines.map { |line| remove_comment(line) }.join("") end |