Class: Hokusai::Util::ClampingIterator
- Inherits:
-
Object
- Object
- Hokusai::Util::ClampingIterator
- Defined in:
- ui/src/hokusai/util/clamping_iterator.rb
Instance Attribute Summary collapse
-
#clamping ⇒ Object
readonly
Returns the value of attribute clamping.
-
#cursor_offset ⇒ Object
Returns the value of attribute cursor_offset.
-
#cursor_position ⇒ Object
Returns the value of attribute cursor_position.
-
#cursor_set ⇒ Object
Returns the value of attribute cursor_set.
-
#height ⇒ Object
Returns the value of attribute height.
-
#on_char_cb ⇒ Object
readonly
Returns the value of attribute on_char_cb.
-
#on_cursor_change_cb ⇒ Object
readonly
Returns the value of attribute on_cursor_change_cb.
-
#on_draw_cb ⇒ Object
readonly
Returns the value of attribute on_draw_cb.
-
#on_draw_selection_cb ⇒ Object
readonly
Returns the value of attribute on_draw_selection_cb.
-
#on_selection_change_cb ⇒ Object
readonly
Returns the value of attribute on_selection_change_cb.
-
#produced ⇒ Object
Returns the value of attribute produced.
-
#segments ⇒ Object
readonly
Returns the value of attribute segments.
-
#start_select ⇒ Object
Returns the value of attribute start_select.
-
#stop_select ⇒ Object
Returns the value of attribute stop_select.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #cursor_x ⇒ Object
- #cursor_y ⇒ Object
- #debug ⇒ Object
-
#initialize(clamping, x, y) ⇒ ClampingIterator
constructor
A new instance of ClampingIterator.
- #next ⇒ Object
- #on_char(&block) ⇒ Object
- #on_cursor_change(&block) ⇒ Object
- #on_draw(&block) ⇒ Object
- #on_draw_selection(&block) ⇒ Object
- #on_selection_change(&block) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize(clamping, x, y) ⇒ ClampingIterator
Returns a new instance of ClampingIterator.
135 136 137 138 139 140 141 142 143 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 135 def initialize(clamping, x, y) @clamping = clamping @x = x @y = y @height = 0 @cursor_offset = 0 @cursor_set = false @i = 0 end |
Instance Attribute Details
#clamping ⇒ Object (readonly)
Returns the value of attribute clamping.
127 128 129 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 127 def clamping @clamping end |
#cursor_offset ⇒ Object
Returns the value of attribute cursor_offset.
132 133 134 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 132 def cursor_offset @cursor_offset end |
#cursor_position ⇒ Object
Returns the value of attribute cursor_position.
132 133 134 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 132 def cursor_position @cursor_position end |
#cursor_set ⇒ Object
Returns the value of attribute cursor_set.
132 133 134 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 132 def cursor_set @cursor_set end |
#height ⇒ Object
Returns the value of attribute height.
132 133 134 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 132 def height @height end |
#on_char_cb ⇒ Object (readonly)
Returns the value of attribute on_char_cb.
127 128 129 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 127 def on_char_cb @on_char_cb end |
#on_cursor_change_cb ⇒ Object (readonly)
Returns the value of attribute on_cursor_change_cb.
127 128 129 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 127 def on_cursor_change_cb @on_cursor_change_cb end |
#on_draw_cb ⇒ Object (readonly)
Returns the value of attribute on_draw_cb.
127 128 129 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 127 def on_draw_cb @on_draw_cb end |
#on_draw_selection_cb ⇒ Object (readonly)
Returns the value of attribute on_draw_selection_cb.
127 128 129 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 127 def on_draw_selection_cb @on_draw_selection_cb end |
#on_selection_change_cb ⇒ Object (readonly)
Returns the value of attribute on_selection_change_cb.
127 128 129 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 127 def on_selection_change_cb @on_selection_change_cb end |
#produced ⇒ Object
Returns the value of attribute produced.
132 133 134 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 132 def produced @produced end |
#segments ⇒ Object (readonly)
Returns the value of attribute segments.
127 128 129 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 127 def segments @segments end |
#start_select ⇒ Object
Returns the value of attribute start_select.
132 133 134 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 132 def start_select @start_select end |
#stop_select ⇒ Object
Returns the value of attribute stop_select.
132 133 134 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 132 def stop_select @stop_select end |
#x ⇒ Object
Returns the value of attribute x.
132 133 134 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 132 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
132 133 134 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 132 def y @y end |
Instance Method Details
#cursor_x ⇒ Object
177 178 179 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 177 def cursor_x x end |
#cursor_y ⇒ Object
173 174 175 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 173 def cursor_y y end |
#debug ⇒ Object
149 150 151 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 149 def debug clamping.debug end |
#next ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 157 def next if @i < segments.size SegmentRenderer.new(segments[@i], self) else if position = cursor_position on_cursor_change_cb&.call(position) end if start = start_select on_selection_change_cb&.call(start, stop_select) end end ensure @i += 1 end |
#on_char(&block) ⇒ Object
197 198 199 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 197 def on_char(&block) @on_char_cb = block end |
#on_cursor_change(&block) ⇒ Object
193 194 195 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 193 def on_cursor_change(&block) @on_cursor_change_cb = block end |
#on_draw(&block) ⇒ Object
181 182 183 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 181 def on_draw(&block) @on_draw_cb = block end |
#on_draw_selection(&block) ⇒ Object
185 186 187 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 185 def on_draw_selection(&block) @on_draw_selection_cb = block end |
#on_selection_change(&block) ⇒ Object
189 190 191 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 189 def on_selection_change(&block) @on_selection_change_cb = block end |
#reset ⇒ Object
145 146 147 |
# File 'ui/src/hokusai/util/clamping_iterator.rb', line 145 def reset @i = 0 end |