Class: TimesWire::Section

Inherits:
Base
  • Object
show all
Defined in:
lib/times_wire/section.rb

Constant Summary

Constants inherited from Base

Base::API_BASE, Base::API_NAME, Base::API_SERVER, Base::API_VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

api_key, api_key=, build_request_url, #copyright, datetime_parser, invoke, semantic_api_key=

Constructor Details

#initialize(params = {}) ⇒ Section

Returns a new instance of Section.



6
7
8
9
10
# File 'lib/times_wire/section.rb', line 6

def initialize(params={})
  params.each_pair do |k,v|
    instance_variable_set("@#{k}", v)
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/times_wire/section.rb', line 4

def name
  @name
end

Class Method Details

.allObject



17
18
19
20
21
# File 'lib/times_wire/section.rb', line 17

def self.all
reply = Base.invoke("section-list", {"limit" => 20})
			results = reply['results']
			sections = results.map {|r| Section.create_from_api(r)}
end

.create_from_api(params = {}) ⇒ Object



12
13
14
15
# File 'lib/times_wire/section.rb', line 12

def self.create_from_api(params={})
  self.new :name => params['section'],
           :display_name => params['display_name']
end