class Mixml::Application::ModifyCommand
Command that selects and modifies nodes
Attributes
optional_expression[RW]
@return [Boolean] Supplying an expression is optional
Public Class Methods
new(method, args = ARGV)
click to toggle source
Initialize a new command
@param method [Symbol] Command method @param args [Array<String>] Command arguments
Calls superclass method
Mixml::Application::SelectCommand::new
# 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
Public Instance Methods
before(args, options)
click to toggle source
Check if an expression is set
# File lib/mixml/application.rb, line 102 def before(args, options) if not @optional_expression and @template.nil? then raise SystemExit, 'Please specify a value with --string or --template.' end end
parameters()
click to toggle source
Return the template as parameter
# File lib/mixml/application.rb, line 109 def parameters [@template] end