Class: RPiet::CodelChooser
- Inherits:
-
Object
- Object
- RPiet::CodelChooser
- Defined in:
- lib/rpiet/codel_chooser.rb
Instance Attribute Summary collapse
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
Instance Method Summary collapse
- #ascii(dp) ⇒ Object
-
#initialize ⇒ CodelChooser
constructor
A new instance of CodelChooser.
- #inspect ⇒ Object (also: #to_s)
- #switch!(amount = 1) ⇒ Object
Constructor Details
#initialize ⇒ CodelChooser
Returns a new instance of CodelChooser.
7 |
# File 'lib/rpiet/codel_chooser.rb', line 7 def initialize; @direction = LEFT; end |
Instance Attribute Details
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
6 7 8 |
# File 'lib/rpiet/codel_chooser.rb', line 6 def direction @direction end |
Instance Method Details
#ascii(dp) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rpiet/codel_chooser.rb', line 10 def ascii(dp) case dp.direction when RPiet::Direction::RIGHT @direction == LEFT ? "^" : "v" when RPiet::Direction::UP @direction == LEFT ? "<" : ">" when RPiet::Direction::LEFT @direction == LEFT ? "v" : "^" when RPiet::Direction::DOWN @direction == LEFT ? ">" : "<" end end |
#inspect ⇒ Object Also known as: to_s
23 24 25 |
# File 'lib/rpiet/codel_chooser.rb', line 23 def inspect (@direction == LEFT ? "left(0)" : "right(1)") end |
#switch!(amount = 1) ⇒ Object
8 |
# File 'lib/rpiet/codel_chooser.rb', line 8 def switch!(amount = 1); @direction *= -1.**(amount % 2); end |