Class: Mixml::Application::ModifyCommand
- Inherits:
-
SelectCommand
- Object
- Commander::Command
- SelectCommand
- Mixml::Application::ModifyCommand
- Defined in:
- lib/mixml/application.rb
Overview
Command that selects and modifies nodes
Instance Attribute Summary collapse
-
#optional_expression ⇒ Boolean
Supplying an expression is optional.
Attributes inherited from SelectCommand
Instance Method Summary collapse
-
#before(args, options) ⇒ Object
Check if an expression is set.
-
#initialize(method, args = ARGV) ⇒ ModifyCommand
constructor
Initialize a new command.
-
#parameters ⇒ Object
Return the template as parameter.
Methods inherited from SelectCommand
Constructor Details
#initialize(method, args = ARGV) ⇒ ModifyCommand
Initialize a new command
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/mixml/application.rb', line 84 def initialize(method, args = ARGV) super(method, args) @template = nil @optional_expression = false option '-s', '--string STRING', String, 'String value' do |value| raise SystemExit, 'Value already specified. Please use --string or --template only once.' unless @template.nil? @template = Mixml::Template::Text.new(value) end option '-t', '--template STRING', String, 'Template expression value' do |value| raise SystemExit, 'Value already specified. Please use --string or --template only once.' unless @template.nil? @template = Mixml::Template::Expression.new(value) end end |
Instance Attribute Details
#optional_expression ⇒ Boolean
Returns Supplying an expression is optional.
78 79 80 |
# File 'lib/mixml/application.rb', line 78 def optional_expression @optional_expression end |
Instance Method Details
#before(args, options) ⇒ Object
Check if an expression is set
102 103 104 105 106 |
# File 'lib/mixml/application.rb', line 102 def before(args, ) if not @optional_expression and @template.nil? then raise SystemExit, 'Please specify a value with --string or --template.' end end |
#parameters ⇒ Object
Return the template as parameter
109 110 111 |
# File 'lib/mixml/application.rb', line 109 def parameters [@template] end |