Class: RDF::CLI::Option
- Inherits:
-
Object
- Object
- RDF::CLI::Option
- Defined in:
- lib/rdf/cli.rb
Overview
Option description for use within Readers/Writers. See Reader.options and Writer.options for example usage.
Instance Attribute Summary collapse
-
#datatype ⇒ Class, Array<String>
readonly
Argument datatype, which may be enumerated string values.
-
#description ⇒ String
readonly
Description of this option (optional).
-
#multiple ⇒ Boolean
readonly
Allows multiple comma-spearated values.
-
#on ⇒ Array<String>
readonly
Arguments passed to OptionParser#on.
-
#symbol ⇒ Symbol
readonly
Symbol used for this option when calling ‘Reader.new`.
Instance Method Summary collapse
- #call(arg) ⇒ Object
-
#initialize(symbol: nil, on: nil, description: nil, datatype: String, multiple: false) {|value| ... } ⇒ Option
constructor
Create a new option with optional callback.
Constructor Details
#initialize(symbol: nil, on: nil, description: nil, datatype: String, multiple: false) {|value| ... } ⇒ Option
Create a new option with optional callback.
109 110 111 112 113 |
# File 'lib/rdf/cli.rb', line 109 def initialize(symbol: nil, on: nil, description: nil, datatype: String, multiple: false, &block) raise ArgumentError, "symbol is a required argument" unless symbol raise ArgumentError, "on is a required argument" unless on @symbol, @on, @description, @datatype, @multiple, @callback = symbol.to_sym, Array(on), description, datatype, multiple, block end |
Instance Attribute Details
#datatype ⇒ Class, Array<String> (readonly)
Argument datatype, which may be enumerated string values
92 93 94 |
# File 'lib/rdf/cli.rb', line 92 def datatype @datatype end |
#description ⇒ String (readonly)
Description of this option (optional)
88 89 90 |
# File 'lib/rdf/cli.rb', line 88 def description @description end |
#multiple ⇒ Boolean (readonly)
Allows multiple comma-spearated values.
96 97 98 |
# File 'lib/rdf/cli.rb', line 96 def multiple @multiple end |
#on ⇒ Array<String> (readonly)
Arguments passed to OptionParser#on
84 85 86 |
# File 'lib/rdf/cli.rb', line 84 def on @on end |
#symbol ⇒ Symbol (readonly)
Symbol used for this option when calling ‘Reader.new`
80 81 82 |
# File 'lib/rdf/cli.rb', line 80 def symbol @symbol end |
Instance Method Details
#call(arg) ⇒ Object
115 116 117 |
# File 'lib/rdf/cli.rb', line 115 def call(arg) @callback ? @callback.call(arg) : arg end |