Class: StepMaster::StepVariable

Inherits:
StepItem
  • Object
show all
Defined in:
lib/step_master/step_variable.rb

Constant Summary collapse

ARG_TEXT_REGEX =
/\(.*?[^\\]\)/

Instance Attribute Summary collapse

Attributes inherited from StepItem

#options, #text

Instance Method Summary collapse

Methods inherited from StepItem

#eql?, #hash, #to_regexp

Constructor Details

#initialize(text, options, name) ⇒ StepVariable

Returns a new instance of StepVariable.



9
10
11
12
13
14
15
16
17
# File 'lib/step_master/step_variable.rb', line 9

def initialize(text, options, name)
	super(text, options)
	@name = name.freeze
	
	raise "#{@text.inspect} is not a variable!" unless @text =~ ARG_TEXT_REGEX
	@easy = @name.nil? ? @text : $` + "<" + @name + ">" + $'
		
	@easy.freeze
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/step_master/step_variable.rb', line 7

def name
  @name
end

Instance Method Details

#inspectObject



23
24
25
# File 'lib/step_master/step_variable.rb', line 23

def inspect
	"#{text.inspect}:#{name.inspect}"
end

#to_s(options = {}) ⇒ Object



19
20
21
# File 'lib/step_master/step_variable.rb', line 19

def to_s(options = {})
	options[:easy] ? @easy  : super()
end