Class: Json2::Body
- Inherits:
-
Object
- Object
- Json2::Body
- Defined in:
- lib/json2/body.rb
Overview
Build a csv body.
Class Method Summary collapse
-
.get(nodes, keys, column_size) ⇒ Object
Get the body of a Csv file.
Instance Method Summary collapse
-
#get ⇒ Object
Get the body of a Csv file.
-
#initialize(nodes, keys, column_size) ⇒ Body
constructor
Creates a new Body instance.
Constructor Details
#initialize(nodes, keys, column_size) ⇒ Body
Creates a new Body instance.
nodes - A Hash representing all columns. The key is the
Symbol column's header and the value is an Array
full of column's values.
keys - An Array of Symbol header’s column. Why passing the
column's names while they are contained in `nodes`?
This is because we want the header's names in that
particular order given by `keys`, we can't rely on
the order of the *Hash* `nodes`.
column_size - The Fixnum size of a column. TODO I think this
parameter isn't needed.
28 29 30 31 32 33 |
# File 'lib/json2/body.rb', line 28 def initialize(nodes, keys, column_size) @nodes = nodes @column_size = column_size @keys = keys @body = '' end |
Class Method Details
.get(nodes, keys, column_size) ⇒ Object
Get the body of a Csv file.
For a description of the parameters see Body#initialize.
Returns the String body, that is several lines in a single string, each lines with comma separated values.
12 13 14 |
# File 'lib/json2/body.rb', line 12 def self.get(nodes, keys, column_size) new(nodes, keys, column_size).get end |
Instance Method Details
#get ⇒ Object
Get the body of a Csv file. See also Body.get.
Returns the String body.
38 39 40 41 |
# File 'lib/json2/body.rb', line 38 def get (0...@column_size).each {|observation| process_line(observation) } @body end |