Class: Syobocal::Comment::Element::Header1

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text_node) ⇒ Header1

Returns a new instance of Header1.



7
8
9
# File 'lib/syobocal/comment/element/header1.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/header1.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/header1.rb', line 15

def self.match?(line)
  !Header2.match?(line) && line.start_with?("*")
end

.parse(line) ⇒ Object



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

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

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

Instance Method Details

#==(other) ⇒ Object



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

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