Class: OCL::IteratorRange

Inherits:
Object
  • Object
show all
Defined in:
lib/dbc/ocl.rb

Overview

Range

Instance Method Summary collapse

Constructor Details

#initialize(declaration, boundry) ⇒ IteratorRange

Returns a new instance of IteratorRange.



70
71
72
73
# File 'lib/dbc/ocl.rb', line 70

def initialize(declaration, boundry)
	@declaration = declaration
	@boundry = boundry
end

Instance Method Details

#close(indent_str) ⇒ Object



90
91
92
# File 'lib/dbc/ocl.rb', line 90

def close(indent_str)
	"#{indent_str}}\n"
end

#declare(indent_str) ⇒ Object



74
75
76
77
78
# File 'lib/dbc/ocl.rb', line 74

def declare(indent_str)
	str = indent_str.dup
	# initialization of variable
	str << @declaration.to_s << ";\n"
end

#open(indent_str) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
# File 'lib/dbc/ocl.rb', line 79

def open(indent_str)
	identifier = @declaration.identifier
	str = ''
	str << indent_str << "for (#{identifier} = #{@boundry.first}; "
	if @boundry.exclude_end?
		str << "#{identifier} < #{@boundry.last}; "
	else
		str << "#{identifier} <= #{@boundry.last}; "
	end
	str << "#{identifier}++) {\n"
end