Class: Fanxobj

Inherits:
Object
  • Object
show all
Defined in:
lib/melody_object/Level_three.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hsh = {}) ⇒ Fanxobj

Returns a new instance of Fanxobj.



78
79
80
81
82
83
84
# File 'lib/melody_object/Level_three.rb', line 78

def initialize(hsh={})
@variable=hsh[:var]||=60
@hilimit=hsh[:hi]||=72
@lolimit=hsh[:lo]||=48
@secondvariable=hsh[:secvar]||=5
@direction=hsh[:dir]||=:up
end

Instance Attribute Details

#directionObject

Returns the value of attribute direction.



75
76
77
# File 'lib/melody_object/Level_three.rb', line 75

def direction
  @direction
end

#hilimitObject

Returns the value of attribute hilimit.



72
73
74
# File 'lib/melody_object/Level_three.rb', line 72

def hilimit
  @hilimit
end

#lolimitObject

Returns the value of attribute lolimit.



74
75
76
# File 'lib/melody_object/Level_three.rb', line 74

def lolimit
  @lolimit
end

#secondvariableObject

Returns the value of attribute secondvariable.



73
74
75
# File 'lib/melody_object/Level_three.rb', line 73

def secondvariable
  @secondvariable
end

#variableObject

Returns the value of attribute variable.



71
72
73
# File 'lib/melody_object/Level_three.rb', line 71

def variable
  @variable
end

Instance Method Details

#fanxObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/melody_object/Level_three.rb', line 86

def fanx
  if @variable>@hilimit then
  @direction=:down
  @variable-=@secondvariable
  elsif @variable<@lolimit then
  @direction=:up
  @variable+=@secondvariable
  else
    case @direction
    when :up
    @variable+=@secondvariable
    when :down
    @variable-=@secondvariable
    end
  end
  #~ @fyl.puts "#{self} #{@variable}"
  return @variable
end