Class: Dub::Parser
- Inherits:
-
Object
- Object
- Dub::Parser
- Defined in:
- lib/dub/parser.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #group(name) ⇒ Object
- #groups ⇒ Object
-
#initialize(filepath) ⇒ Parser
constructor
A new instance of Parser.
- #namespace(name) ⇒ Object
- #namespaces ⇒ Object
Constructor Details
#initialize(filepath) ⇒ Parser
Returns a new instance of Parser.
7 8 9 10 |
# File 'lib/dub/parser.rb', line 7 def initialize(filepath) @current_dir = File.dirname(filepath) @xml = Hpricot::XML(File.read(filepath)) end |
Instance Method Details
#[](name) ⇒ Object
12 13 14 |
# File 'lib/dub/parser.rb', line 12 def [](name) namespaces[name.to_s] || groups[name.to_s] end |
#group(name) ⇒ Object
20 21 22 |
# File 'lib/dub/parser.rb', line 20 def group(name) groups[name.to_s] end |
#groups ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/dub/parser.rb', line 35 def groups @groups ||= begin groups = {} (@xml/'compounddef[@kind=group]').each do |namespace| name = (namespace/"compoundname").innerHTML groups[name] = Dub::Group.new(name, namespace, @current_dir) end groups end end |
#namespace(name) ⇒ Object
16 17 18 |
# File 'lib/dub/parser.rb', line 16 def namespace(name) namespaces[name.to_s] end |
#namespaces ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dub/parser.rb', line 24 def namespaces @namespaces ||= begin ns = {} (@xml/'compounddef[@kind=namespace]').each do |namespace| name = (namespace/"compoundname").innerHTML ns[name] = Dub::Namespace.new(name, namespace, @current_dir) end ns end end |