Class: Queryitis::Response
- Inherits:
-
Object
- Object
- Queryitis::Response
- Includes:
- Enumerable
- Defined in:
- lib/queryitis.rb
Overview
end Query
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Instance Method Summary collapse
-
#common_names ⇒ Object
end success?.
-
#each ⇒ Object
end latin_names.
-
#initialize(data) ⇒ Response
constructor
A new instance of Response.
-
#latin_names ⇒ Object
end common_names.
-
#success? ⇒ Boolean
end initialize.
Constructor Details
#initialize(data) ⇒ Response
Returns a new instance of Response.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/queryitis.rb', line 20 def initialize(data) @data = data @entries = [] @data.each do |entry| @entries << Hash[ "common_name", entry[:common_name_list][:common_names][:common_name], "latin_name", entry[:sci_name], "itis_id", entry[:tsn] ] end # end data.each end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
18 19 20 |
# File 'lib/queryitis.rb', line 18 def data @data end |
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
18 19 20 |
# File 'lib/queryitis.rb', line 18 def entries @entries end |
Instance Method Details
#common_names ⇒ Object
end success?
37 38 39 40 41 42 43 44 |
# File 'lib/queryitis.rb', line 37 def common_names names = [] @data.each do |entry| names << entry[:common_name_list][:common_names][:common_name] end # data.each names end |
#each ⇒ Object
end latin_names
55 56 57 58 59 |
# File 'lib/queryitis.rb', line 55 def each entries.each do |entry| yield entry end # end entries.each end |
#latin_names ⇒ Object
end common_names
46 47 48 49 50 51 52 53 |
# File 'lib/queryitis.rb', line 46 def latin_names names = [] @data.each do |entry| names << entry[:sci_name] end # end data.each names end |
#success? ⇒ Boolean
end initialize
33 34 35 |
# File 'lib/queryitis.rb', line 33 def success? @data != nil end |