Class: Rightstuff::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/rightstuff/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(client, item) ⇒ Base
Returns a new instance of Base.
27
28
29
30
|
# File 'lib/rightstuff/base.rb', line 27
def initialize( client, item )
@client = client
@attributes = Base.( item )
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
32
33
34
|
# File 'lib/rightstuff/base.rb', line 32
def method_missing( name, *args, &block )
return @attributes[ name ]
end
|
Class Method Details
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/rightstuff/base.rb', line 14
def self.( parent )
elements = parent.children.collect do | node |
node.class == Nokogiri::XML::Element ? node : nil
end
elements.compact!
elements.reduce( {} ) do | memo, element |
name = element.name
name.gsub!( /-/, '_' )
memo[ name.intern ] = element.children[ 0 ].to_s
memo
end
end
|
.load_collection(client, doc) ⇒ Object
8
9
10
11
12
|
# File 'lib/rightstuff/base.rb', line 8
def self.load_collection( client, doc )
doc.xpath( self.collection_xpath ).collect do | item |
self.new( client, item )
end
end
|