Class: CTG::Response::CSVResponse
- Inherits:
-
CTG::Response
- Object
- CTG::Response
- CTG::Response::CSVResponse
- Defined in:
- lib/ctg/response/csv_response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Attributes inherited from CTG::Response
Instance Method Summary collapse
-
#initialize(response_body, client) ⇒ CSVResponse
constructor
Initializes the CSVResponse object by parsing the CSV data.
-
#query(column_name) ⇒ Array<String>
Queries the CSV data by column name.
Methods inherited from CTG::Response
Constructor Details
#initialize(response_body, client) ⇒ CSVResponse
Initializes the CSVResponse object by parsing the CSV data
21 22 23 24 |
# File 'lib/ctg/response/csv_response.rb', line 21 def initialize(response_body, client) super(client) @data = CSV.parse(response_body, headers: true) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
16 17 18 |
# File 'lib/ctg/response/csv_response.rb', line 16 def data @data end |
Instance Method Details
#query(column_name) ⇒ Array<String>
Queries the CSV data by column name
29 30 31 |
# File 'lib/ctg/response/csv_response.rb', line 29 def query(column_name) @data.map { |row| row[column_name] }.compact end |