Class: HTOTConv::CLI::ScriptOptions
- Inherits:
-
Object
- Object
- HTOTConv::CLI::ScriptOptions
- Defined in:
- lib/htot_conv/cli.rb
Instance Attribute Summary collapse
-
#from_options ⇒ Object
readonly
Returns the value of attribute from_options.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#to_options ⇒ Object
readonly
Returns the value of attribute to_options.
Instance Method Summary collapse
- #define_options(opts, io_filter = false) ⇒ Object
- #freeze ⇒ Object
-
#initialize ⇒ ScriptOptions
constructor
A new instance of ScriptOptions.
Constructor Details
#initialize ⇒ ScriptOptions
Returns a new instance of ScriptOptions.
9 10 11 12 13 14 15 16 |
# File 'lib/htot_conv/cli.rb', line 9 def initialize @options = { :from_type => :simple_text, :to_type => :xlsx_type2, } @from_options = {} @to_options = {} end |
Instance Attribute Details
#from_options ⇒ Object (readonly)
Returns the value of attribute from_options.
17 18 19 |
# File 'lib/htot_conv/cli.rb', line 17 def @from_options end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'lib/htot_conv/cli.rb', line 17 def @options end |
#to_options ⇒ Object (readonly)
Returns the value of attribute to_options.
17 18 19 |
# File 'lib/htot_conv/cli.rb', line 17 def @to_options end |
Instance Method Details
#define_options(opts, io_filter = false) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/htot_conv/cli.rb', line 26 def (opts, io_filter=false) opts. = %q{Hierarchical-Tree Outline Text Converter} opts.define_head %q{Usage: htot_conv [options] [input] [output]} opts.separator %q{} opts.separator %q{Options:} from_types = HTOTConv::Parser.types.map { |v| [v, v.to_s.tr("_", "-")] }.flatten to_types = HTOTConv::Generator.types.map { |v| [v, v.to_s.tr("_", "-")] }.flatten opts.on("-f", "--from-type=TYPE", from_types, "type of input (default: #{[:from_type]})") do |v| @options[:from_type] = v.to_s.tr("-", "_") end opts.on("-t", "--to-type=TYPE", to_types, "type of output (default: #{[:to_type]})") do |v| @options[:to_type] = v.to_s.tr("-", "_") end opts.on("-l", "--list-type", "list input/output type") do $stdout << "type of input:\n" $stdout << HTOTConv::Parser.types.join(" ") << "\n" $stdout << "\n" $stdout << "type of output:\n" $stdout << HTOTConv::Generator.types.join(" ") << "\n" $stdout << "\n" exit end opts.separator "" opts.on("-h", "-?", "--help", "Show this message") do puts opts exit end opts.on("--version", "Show version") do $stdout << "htot_conv #{HTOTConv::VERSION}\n" exit end opts.separator "" opts.separator "I/O Options:" if io_filter (opts, HTOTConv::Parser, @options[:from_type], "from") do |key, v| @from_options[key] = v end (opts, HTOTConv::Generator, @options[:to_type], "to") do |key, v| @to_options[key] = v end else (opts, HTOTConv::Parser, "from") do |key, v| @from_options[key] = v end (opts, HTOTConv::Generator, "to") do |key, v| @to_options[key] = v end end end |
#freeze ⇒ Object
19 20 21 22 23 24 |
# File 'lib/htot_conv/cli.rb', line 19 def freeze @options.freeze @from_options.freeze @to_options.freeze super end |