Class: Syobocal::Comment::Element::List

Inherits:
Object
  • Object
show all
Defined in:
lib/syobocal/comment/element/list.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text_node) ⇒ List

Returns a new instance of List.



7
8
9
# File 'lib/syobocal/comment/element/list.rb', line 7

def initialize(text_node)
  @text_node = text_node
end

Instance Attribute Details

#text_nodeObject (readonly)

Returns the value of attribute text_node.



5
6
7
# File 'lib/syobocal/comment/element/list.rb', line 5

def text_node
  @text_node
end

Class Method Details

.match?(line) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/syobocal/comment/element/list.rb', line 15

def self.match?(line)
  line.start_with?("-")
end

.parse(line) ⇒ Object



19
20
21
22
23
# File 'lib/syobocal/comment/element/list.rb', line 19

def self.parse(line)
  txt = line.match(/\A-(.*)\Z/)[1]

  Element::List.new(Element::TextNode.parse(txt))
end

Instance Method Details

#==(other) ⇒ Object



11
12
13
# File 'lib/syobocal/comment/element/list.rb', line 11

def ==(other)
  other.instance_of?(self.class) && other.text_node == text_node
end