Class: Flickr::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/flickr/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, name) ⇒ Node

Returns a new instance of Node.



7
8
9
# File 'lib/flickr/node.rb', line 7

def initialize(client, name)
  @client, @name = client, name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object (protected)



25
26
27
28
# File 'lib/flickr/node.rb', line 25

def method_missing(method_name, *args)
  node = Flickr::Node.new(client, [name, method_name].join('.'))
  node.require_parameters? and args.first.is_a?(Hash) ? node.invoke(args.first) : node
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/flickr/node.rb', line 5

def client
  @client
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/flickr/node.rb', line 5

def name
  @name
end

Instance Method Details

#invoke(params = {}) ⇒ Object



15
16
17
# File 'lib/flickr/node.rb', line 15

def invoke(params = {})
  client.get(Flickr::REST_PATH, params.merge(:method => name))
end

#require_parameters?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/flickr/node.rb', line 11

def require_parameters?
  true
end

#to_sObject



19
20
21
# File 'lib/flickr/node.rb', line 19

def to_s
  name
end