Class: Alpinist::Profile
- Inherits:
-
Object
- Object
- Alpinist::Profile
- Defined in:
- lib/alpinist/profile.rb
Instance Attribute Summary collapse
-
#root_nodes ⇒ Object
readonly
Returns the value of attribute root_nodes.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #all_descriptors ⇒ Object
- #find_descriptor(id) ⇒ Object
- #find_node(id) ⇒ Object
-
#initialize(document, url) ⇒ Profile
constructor
A new instance of Profile.
- #root_descriptors ⇒ Object
Constructor Details
#initialize(document, url) ⇒ Profile
Returns a new instance of Profile.
8 9 10 11 12 13 14 15 |
# File 'lib/alpinist/profile.rb', line 8 def initialize(document, url) @document = document @url = url @root_nodes = [] @descriptors = {} @insubstantial_descriptors = [] parse! end |
Instance Attribute Details
#root_nodes ⇒ Object (readonly)
Returns the value of attribute root_nodes.
6 7 8 |
# File 'lib/alpinist/profile.rb', line 6 def root_nodes @root_nodes end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/alpinist/profile.rb', line 6 def url @url end |
Instance Method Details
#all_descriptors ⇒ Object
32 33 34 |
# File 'lib/alpinist/profile.rb', line 32 def all_descriptors @descriptors.values end |
#find_descriptor(id) ⇒ Object
23 24 25 26 |
# File 'lib/alpinist/profile.rb', line 23 def find_descriptor(id) id = id.sub(/^#/, '') @descriptors[id] || @insubstantial_descriptors.find { |descriptor| descriptor.id == id } end |
#find_node(id) ⇒ Object
17 18 19 20 21 |
# File 'lib/alpinist/profile.rb', line 17 def find_node(id) @root_nodes.inject(nil) do |result, root_node| result || root_node.find { |node| node.name == id && node.content.reference.nil? } end end |
#root_descriptors ⇒ Object
28 29 30 |
# File 'lib/alpinist/profile.rb', line 28 def root_descriptors @root_nodes.map(&:content) end |