Class: Cocoadex::SequentialNodeElement

Inherits:
Element
  • Object
show all
Defined in:
lib/cocoadex/models/seq_node_element.rb

Overview

An element of a section where each item is divided by anchor tags

Direct Known Subclasses

ConstantGroup, DataType, Function

Constant Summary collapse

Abstract =
->(node) { node.classes.include? "abstract"     }
Declaration =
->(node) { node.classes.include? "declaration"  }
ReturnValue =
->(node) { node.classes.include? "return_value" }
Discussion =
->(node) { node.classes.include? "discussion"   }
Availability =
->(node) { node.classes.include? "availability" }
DeclaredIn =
->(node) { node.classes.include? "declaredIn"   }
Special =
->(node) { node.classes.include? "specialConsiderations" }

Instance Attribute Summary

Attributes inherited from Element

#name

Instance Method Summary collapse

Methods inherited from Element

#<=>, #parse_parameters, #print, #to_s, #type

Methods included from Bri::Templates::Helpers

h3, inline_title, wrap

Constructor Details

#initialize(origin, title_node) ⇒ SequentialNodeElement

Returns a new instance of SequentialNodeElement.



14
15
16
17
18
# File 'lib/cocoadex/models/seq_node_element.rb', line 14

def initialize origin, title_node
  @origin = origin
  @name = title_node.text
  parse(title_node)
end

Instance Method Details

#handle_node(node) ⇒ Object



49
50
51
# File 'lib/cocoadex/models/seq_node_element.rb', line 49

def handle_node node
  logger.debug("Unhandled #{self.class} property: #{classes} => #{node.text}")
end

#originObject



20
21
22
# File 'lib/cocoadex/models/seq_node_element.rb', line 20

def origin
  @origin
end

#parse(title_node) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cocoadex/models/seq_node_element.rb', line 24

def parse title_node
  prev_node = title_node
  while node = prev_node.next and node.name != "a"
    case node
    when Abstract
      @abstract = node.text
    when Declaration
      @declaration = node.text
    when Availability
      @availability = node.text.sub("Availability","")
    when ReturnValue
      @return_value = node.text.sub("Return Value","")
    when Discussion
      @discussion = node.text.sub("Discussion","")
    when DeclaredIn
      @declared_in = node.text.sub("Declared In","")
    when Special
      @considerations = node.text.sub("Special Considerations","")
    else
      handle_node(node)
    end
    prev_node = node
  end
end