Module: Acclaim::Option::Type
- Extended by:
- Enumerable
- Defined in:
- lib/acclaim/option/type.rb,
lib/acclaim/option/type/uri.rb,
lib/acclaim/option/type/date.rb,
lib/acclaim/option/type/time.rb,
lib/acclaim/option/type/float.rb,
lib/acclaim/option/type/string.rb,
lib/acclaim/option/type/symbol.rb,
lib/acclaim/option/type/complex.rb,
lib/acclaim/option/type/integer.rb,
lib/acclaim/option/type/pathname.rb,
lib/acclaim/option/type/rational.rb,
lib/acclaim/option/type/date_time.rb,
lib/acclaim/option/type/big_decimal.rb
Overview
Associates a class with a handler block.
Defined Under Namespace
Modules: BigDecimal, Complex, Date, DateTime, Float, Integer, Pathname, Rational, String, Symbol, Time, URI
Class Method Summary collapse
-
.all ⇒ Array<Class, Module>
(also: registered)
Returns all registered classes.
-
.each {|type, handler| ... } ⇒ Object
Yields class, proc pairs if a block was given.
-
.handler_for(type) ⇒ Object
(also: [])
Returns the handler for the given class.
-
.register(*types, &block) {|string| ... } ⇒ Object
(also: add_handler_for, accept)
Registers a handler for a class.
Class Method Details
.all ⇒ Array<Class, Module> Also known as: registered
Returns all registered classes.
29 30 31 |
# File 'lib/acclaim/option/type.rb', line 29 def all table.keys end |
.each {|type, handler| ... } ⇒ Object
Yields class, proc pairs if a block was given. Returns an enumerator otherwise.
19 20 21 |
# File 'lib/acclaim/option/type.rb', line 19 def each(&block) table.each &block end |
.handler_for(type) ⇒ Object Also known as: []
Returns the handler for the given class.
51 52 53 54 55 |
# File 'lib/acclaim/option/type.rb', line 51 def handler_for(type) table.fetch type do raise "#{type} does not have an associated handler" end end |
.register(*types, &block) {|string| ... } ⇒ Object Also known as: add_handler_for, accept
Registers a handler for a class.
41 42 43 |
# File 'lib/acclaim/option/type.rb', line 41 def register(*types, &block) types.each { |type| table[type] = block } end |