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)



51
52
53
54
# File 'lib/flickr/node.rb', line 51

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
18
19
20
# File 'lib/flickr/node.rb', line 15

def invoke(params = {})
  params = params.dup
  connection_options = extract_connection_options(params)
  response = client.connection(connection_options).get(build_rest_query(params))
  response.body
end

#require_parameters?Boolean

Returns:

  • (Boolean)


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

def require_parameters?
  true
end

#to_sObject



22
23
24
# File 'lib/flickr/node.rb', line 22

def to_s
  name
end