Class: FlickRaw::Response
- Inherits:
-
Object
- Object
- FlickRaw::Response
- Defined in:
- lib/flickraw.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:
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/flickraw.rb', line 63 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;" } eval methods << "end" end |
Instance Attribute Details
#flickr_type ⇒ Object (readonly)
Returns the value of attribute flickr_type.
62 63 64 |
# File 'lib/flickraw.rb', line 62 def flickr_type @flickr_type end |
Class Method Details
.build(h, type) ⇒ Object
:nodoc:
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/flickraw.rb', line 50 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
76 |
# File 'lib/flickraw.rb', line 76 def [](k); @h[k] end |
#inspect ⇒ Object
78 |
# File 'lib/flickraw.rb', line 78 def inspect; @h.inspect end |
#marshal_dump ⇒ Object
80 |
# File 'lib/flickraw.rb', line 80 def marshal_dump; [@h, @flickr_type] end |
#marshal_load(data) ⇒ Object
81 |
# File 'lib/flickraw.rb', line 81 def marshal_load(data); initialize(*data) end |
#to_hash ⇒ Object
79 |
# File 'lib/flickraw.rb', line 79 def to_hash; @h end |
#to_s ⇒ Object
77 |
# File 'lib/flickraw.rb', line 77 def to_s; @h["_content"] || super end |