Class: Ss2Json::Cli
- Inherits:
-
Object
- Object
- Ss2Json::Cli
- Defined in:
- lib/ss2json/cli.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
Class Method Summary collapse
-
.start ⇒ Object
Parse the options from ARGV, initialize the conversion, and return the string with the output.
Instance Method Summary collapse
-
#initialize(options) ⇒ Cli
constructor
Create a new converter the options are:.
Constructor Details
#initialize(options) ⇒ Cli
Create a new converter the options are:
* **:file** Input file.
* **:sheet** Name of the sheet to use.
* **:first_row** Where the title of the columns is.
* **:check_column** Output only the results with a value present on the specific field.
* **:orientation** The data orientation (:horizontal/:vertical).
* **:key_column** Column of the keys for vertical mode.
* **:value_column** Column of the values.
* **:action** Could
* *:convert* Do the normal conversion.
* *:list* Will list the sheets.
* **:converter**: Options passed to the converter: Ss2Json::RowConverter
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ss2json/cli.rb', line 34 def initialize() @options = init_document if [:action] == :list @doc.sheets.join("\n") else if [:orientation] == :horizontal @options[:first_row] += 1 process_horizontal elsif [:orientation] == :vertical process_vertical else raise "Orientation #{[:orientation]} not recognized" end end end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'lib/ss2json/cli.rb', line 7 def content @content end |
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
7 8 9 |
# File 'lib/ss2json/cli.rb', line 7 def doc @doc end |
Class Method Details
.start ⇒ Object
Parse the options from ARGV, initialize the conversion, and return the string with the output
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ss2json/cli.rb', line 10 def self.start = Ss2Json::Options.parse! converter = new() case [:action] when :list converter.doc.sheets.join("\n") else JSON.pretty_generate(converter.content) end end |