Class: Factual::Fact
- Inherits:
-
Object
- Object
- Factual::Fact
- Defined in:
- lib/factual.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#field ⇒ Object
Returns the value of attribute field.
-
#subject_key ⇒ Object
Returns the value of attribute subject_key.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #field_ref ⇒ Object
-
#initialize(table, subject_key, field, value) ⇒ Fact
constructor
A new instance of Fact.
- #input(value, opts = {}) ⇒ Object
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(table, subject_key, field, value) ⇒ Fact
Returns a new instance of Fact.
121 122 123 124 125 126 127 128 |
# File 'lib/factual.rb', line 121 def initialize(table, subject_key, field, value) @value = value @field = field @subject_key = subject_key @table_key = table.key @adapter = table.adapter end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
119 120 121 |
# File 'lib/factual.rb', line 119 def adapter @adapter end |
#field ⇒ Object
Returns the value of attribute field.
119 120 121 |
# File 'lib/factual.rb', line 119 def field @field end |
#subject_key ⇒ Object
Returns the value of attribute subject_key.
119 120 121 |
# File 'lib/factual.rb', line 119 def subject_key @subject_key end |
#value ⇒ Object
Returns the value of attribute value.
119 120 121 |
# File 'lib/factual.rb', line 119 def value @value end |
Instance Method Details
#field_ref ⇒ Object
130 131 132 |
# File 'lib/factual.rb', line 130 def field_ref @field["field_ref"] end |
#input(value, opts = {}) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/factual.rb', line 134 def input(value, opts={}) return false if value.nil? hash = opts.merge({ :subjectKey => @subject_key, :fieldId => @field['id'], :value => value }) query_string = hash.to_a.collect{ |k,v| URI.escape(k.to_s) + '=' + URI.escape(v.to_s) }.join('&') @adapter.api_call("/tables/#{@table_key}/input.js?" + query_string) return true end |
#inspect ⇒ Object
152 153 154 |
# File 'lib/factual.rb', line 152 def inspect @value end |
#to_s ⇒ Object
148 149 150 |
# File 'lib/factual.rb', line 148 def to_s @value end |