Class: FlickRaw::Response
- Inherits:
-
Object
- Object
- FlickRaw::Response
- Defined in:
- lib/flickraw/response.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#flickr_type ⇒ Object
readonly
Returns the value of attribute flickr_type.
Class Method Summary collapse
-
.build(h, type) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #[](k) ⇒ Object
-
#initialize(h, type) ⇒ Response
constructor
:nodoc:.
- #inspect ⇒ Object
- #marshal_dump ⇒ Object
- #marshal_load(data) ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(h, type) ⇒ Response
:nodoc:
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/flickraw/response.rb', line 16 def initialize(h, type) # :nodoc: @flickr_type, @h = type, {} methods = "class << self;" h.each {|k,v| @h[k] = case v when Hash then Response.build(v, k) when Array then v.collect {|e| Response.build(e, k)} else v end methods << "def #{k}; @h['#{k}'] end;" if Util.safe_for_eval?(k) } eval methods << "end" end |
Instance Attribute Details
#flickr_type ⇒ Object (readonly)
Returns the value of attribute flickr_type.
15 16 17 |
# File 'lib/flickraw/response.rb', line 15 def flickr_type @flickr_type end |
Class Method Details
.build(h, type) ⇒ Object
:nodoc:
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/flickraw/response.rb', line 3 def self.build(h, type) # :nodoc: if h.is_a? Response h elsif type =~ /s$/ and (a = h[$`]).is_a? Array ResponseList.new(h, type, a.collect {|e| Response.build(e, $`)}) elsif h.keys == ["_content"] h["_content"] else Response.new(h, type) end end |
Instance Method Details
#[](k) ⇒ Object
29 |
# File 'lib/flickraw/response.rb', line 29 def [](k); @h[k] end |
#inspect ⇒ Object
31 |
# File 'lib/flickraw/response.rb', line 31 def inspect; @h.inspect end |
#marshal_dump ⇒ Object
33 |
# File 'lib/flickraw/response.rb', line 33 def marshal_dump; [@h, @flickr_type] end |
#marshal_load(data) ⇒ Object
34 |
# File 'lib/flickraw/response.rb', line 34 def marshal_load(data); initialize(*data) end |
#to_hash ⇒ Object
32 |
# File 'lib/flickraw/response.rb', line 32 def to_hash; @h end |
#to_s ⇒ Object
30 |
# File 'lib/flickraw/response.rb', line 30 def to_s; @h["_content"] || super end |