Class: Sistrix::Domain::Age
- Inherits:
-
Object
- Object
- Sistrix::Domain::Age
- Includes:
- Base
- Defined in:
- lib/sistrix/domain/age.rb
Instance Attribute Summary collapse
-
#age ⇒ Object
readonly
Returns the value of attribute age.
-
#credits ⇒ Object
readonly
Returns the value of attribute credits.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
Instance Method Summary collapse
- #call(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Age
constructor
A new instance of Age.
Methods included from Base
#base_uri, #fetch, #method_name
Constructor Details
#initialize(options = {}) ⇒ Age
Returns a new instance of Age.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sistrix/domain/age.rb', line 9 def initialize( = {}) @options = { 'domain' => nil, 'api_key' => Sistrix.config.api_key, }.merge() if Sistrix.config.proxy RestClient.proxy = Sistrix.config.proxy end end |
Instance Attribute Details
#age ⇒ Object (readonly)
Returns the value of attribute age.
7 8 9 |
# File 'lib/sistrix/domain/age.rb', line 7 def age @age end |
#credits ⇒ Object (readonly)
Returns the value of attribute credits.
7 8 9 |
# File 'lib/sistrix/domain/age.rb', line 7 def credits @credits end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
7 8 9 |
# File 'lib/sistrix/domain/age.rb', line 7 def domain @domain end |
Instance Method Details
#call(options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sistrix/domain/age.rb', line 20 def call( = {}) data = fetch() @credits = data.xpath('//credits').first['used'].to_i age_node = data.xpath('//answer/age').first @age = Time.parse(age_node['value']) @domain = age_node['domain'] self end |