Class: Megalith::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/megalith/scheme.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url, index) ⇒ Index

Returns a new instance of Index.



171
172
173
174
# File 'lib/megalith/scheme.rb', line 171

def initialize(base_url, index)
  @base_url = base_url
  @index = index
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(action, *args) ⇒ Object



176
177
178
# File 'lib/megalith/scheme.rb', line 176

def method_missing(action, *args)
  return @index[action.to_s.to_sym] rescue nil
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



169
170
171
# File 'lib/megalith/scheme.rb', line 169

def base_url
  @base_url
end

#indexObject (readonly)

Returns the value of attribute index.



170
171
172
# File 'lib/megalith/scheme.rb', line 170

def index
  @index
end

Instance Method Details

#fetchObject Also known as: get



187
188
189
# File 'lib/megalith/scheme.rb', line 187

def fetch
  Novel.new(@base_url, self.log, self.key)
end

#paramsObject Also known as: available_methods



180
# File 'lib/megalith/scheme.rb', line 180

def params() @index.keys.map{|k|k.to_sym} ; end

#to_hashObject



183
184
185
# File 'lib/megalith/scheme.rb', line 183

def to_hash
  @index
end