class RDF::CLI::Option

Option description for use within Readers/Writers. See {RDF::Reader.options} and {RDF::Writer.options} for example usage.

Attributes

datatype[R]

Argument datatype, which may be enumerated string values @return [Class, Array<String>]

description[R]

Description of this option (optional) @return [String]

multiple[R]

Allows multiple comma-spearated values. @return [Boolean]

on[R]

Arguments passed to OptionParser#on @return [Array<String>]

symbol[R]

Symbol used for this option when calling `Reader.new` @return [Symbol]

Public Class Methods

new(symbol: nil, on: nil, description: nil, datatype: String, multiple: false, &block) click to toggle source

Create a new option with optional callback.

@param [Symbol] symbol @param [Array<String>] on @param [String] description @param [Class, Array<String>] datatype of value @param [Boolean] multiple can have multiple comma-separated values @yield value which may be used within `OptionParser#on` @yieldparam [Object] value The option value as parsed using `on` argument @yieldreturn [Object] a possibly modified input value

# 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

Public Instance Methods

call(arg) click to toggle source
# File lib/rdf/cli.rb, line 115
def call(arg)
  @callback ? @callback.call(arg) : arg
end