Class: Tweetkit::Response::Tweets::Fields::Field
- Inherits:
-
Object
- Object
- Tweetkit::Response::Tweets::Fields::Field
- Includes:
- Enumerable
- Defined in:
- lib/tweetkit/response.rb
Constant Summary collapse
- FIELD_NORMALIZATION_KEY =
{ 'users': 'id' }.freeze
Instance Attribute Summary collapse
-
#normalized_field ⇒ Object
Returns the value of attribute normalized_field.
-
#original_field ⇒ Object
Returns the value of attribute original_field.
Instance Method Summary collapse
- #each(*args, &block) ⇒ Object
- #each_data(*args, &block) ⇒ Object
- #find(key) ⇒ Object
-
#initialize(field, field_type) ⇒ Field
constructor
A new instance of Field.
Constructor Details
#initialize(field, field_type) ⇒ Field
Returns a new instance of Field.
586 587 588 589 590 591 592 593 594 |
# File 'lib/tweetkit/response.rb', line 586 def initialize(field, field_type) @original_field = field @normalized_field = {} normalization_key = FIELD_NORMALIZATION_KEY[field_type.to_sym] field.each do |data| key = data[normalization_key] @normalized_field[key.to_i] = data end end |
Instance Attribute Details
#normalized_field ⇒ Object
Returns the value of attribute normalized_field.
580 581 582 |
# File 'lib/tweetkit/response.rb', line 580 def normalized_field @normalized_field end |
#original_field ⇒ Object
Returns the value of attribute original_field.
580 581 582 |
# File 'lib/tweetkit/response.rb', line 580 def original_field @original_field end |
Instance Method Details
#each(*args, &block) ⇒ Object
596 597 598 |
# File 'lib/tweetkit/response.rb', line 596 def each(*args, &block) @normalized_field.each(*args, &block) end |
#each_data(*args, &block) ⇒ Object
600 601 602 |
# File 'lib/tweetkit/response.rb', line 600 def each_data(*args, &block) @normalized_field.values.each(*args, &block) end |
#find(key) ⇒ Object
604 605 606 |
# File 'lib/tweetkit/response.rb', line 604 def find(key) @normalized_field[key.to_i] end |