Class: Resas::Api::Client::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/resas/api/client/path.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_version, *namespaces, options) ⇒ Path

Returns a new instance of Path.

Raises:

  • (TypeError)


15
16
17
18
19
20
21
22
23
24
# File 'lib/resas/api/client/path.rb', line 15

def initialize( api_version, *namespaces, options )
  raise TypeError unless namespaces.instance_of?( Array )
  raise TypeError unless options.instance_of?( Hash )

  @api_version = api_version
  @namespaces = namespaces.flatten.map( &:to_s ).map { | str |
    str.split( '/' ).map { | str2 | str2.camelize( :lower ) }
  }.flatten
  @options = options
end

Class Method Details

.get(api_version, *args) ⇒ Object



8
9
10
11
12
13
# File 'lib/resas/api/client/path.rb', line 8

def self.get( api_version, *args )
  args = [ args ]
  args.flatten!
  options = args.extract_options!
  new( api_version, *args, options ).to_s
end

Instance Method Details

#to_sObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/resas/api/client/path.rb', line 26

def to_s
  result = '/' + dirs.join( '/' )
  _queries = queries

  if _queries.present?
    result += "?#{ _queries }"
  end

  result
end