Class: Sistrix::Links::Linktargets
- Inherits:
-
Object
- Object
- Sistrix::Links::Linktargets
- Includes:
- Base
- Defined in:
- lib/sistrix/links/linktargets.rb
Defined Under Namespace
Classes: Record
Instance Attribute Summary collapse
-
#credits ⇒ Object
readonly
Returns the value of attribute credits.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Instance Method Summary collapse
- #call(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Linktargets
constructor
A new instance of Linktargets.
Methods included from Base
#base_uri, #fetch, #method_name
Constructor Details
#initialize(options = {}) ⇒ Linktargets
Returns a new instance of Linktargets.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sistrix/links/linktargets.rb', line 11 def initialize( = {}) @options = { 'domain' => nil, 'num' => nil, 'api_key' => Sistrix.config.api_key, }.merge() if Sistrix.config.proxy RestClient.proxy = Sistrix.config.proxy end end |
Instance Attribute Details
#credits ⇒ Object (readonly)
Returns the value of attribute credits.
9 10 11 |
# File 'lib/sistrix/links/linktargets.rb', line 9 def credits @credits end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
9 10 11 |
# File 'lib/sistrix/links/linktargets.rb', line 9 def targets @targets end |
Instance Method Details
#call(options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sistrix/links/linktargets.rb', line 23 def call( = {}) data = fetch() @credits = data.xpath('/response/credits').first['used'].to_i @targets = [] data.xpath('/response/answer/target').each do |r| @targets << Record.new(r) end self end |