Class: LazyDoc::Commands::AsClassCommand
- Inherits:
-
Object
- Object
- LazyDoc::Commands::AsClassCommand
- Defined in:
- lib/lazy_doc/commands/as_class_command.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #execute(value) ⇒ Object
-
#initialize(klass) ⇒ AsClassCommand
constructor
A new instance of AsClassCommand.
Constructor Details
#initialize(klass) ⇒ AsClassCommand
Returns a new instance of AsClassCommand.
5 6 7 |
# File 'lib/lazy_doc/commands/as_class_command.rb', line 5 def initialize(klass) @klass = klass end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
3 4 5 |
# File 'lib/lazy_doc/commands/as_class_command.rb', line 3 def klass @klass end |
Instance Method Details
#execute(value) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/lazy_doc/commands/as_class_command.rb', line 9 def execute(value) if klass.nil? value else if value.is_a? Array value.map { |element| klass.new(element) } else klass.new(value) end end end |