Class: HtmlSlicer::Helpers::Slicer::SliceProxy
- Inherits:
-
Object
- Object
- HtmlSlicer::Helpers::Slicer::SliceProxy
- Includes:
- Comparable
- Defined in:
- lib/html_slicer/helpers/slicer.rb
Overview
Wraps a “slice number” and provides some utility methods
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #<=>(other) ⇒ Object
-
#current? ⇒ Boolean
current slice or not.
-
#first? ⇒ Boolean
the first slice or not.
-
#initialize(options, slice, last) ⇒ SliceProxy
constructor
:nodoc:.
-
#inside_window? ⇒ Boolean
inside the inner window or not.
-
#last? ⇒ Boolean
the last slice or not.
-
#left_outer? ⇒ Boolean
within the left outer window or not.
-
#next? ⇒ Boolean
the next slice or not.
-
#number ⇒ Object
the slice number.
-
#prev? ⇒ Boolean
the previous slice or not.
-
#right_outer? ⇒ Boolean
within the right outer window or not.
- #to_i ⇒ Object
- #to_s ⇒ Object
-
#was_truncated? ⇒ Boolean
The last rendered tag was “truncated” or not.
Constructor Details
#initialize(options, slice, last) ⇒ SliceProxy
:nodoc:
108 109 110 |
# File 'lib/html_slicer/helpers/slicer.rb', line 108 def initialize(, slice, last) #:nodoc: @options, @slice, @last = , slice, last end |
Instance Method Details
#+(other) ⇒ Object
170 171 172 |
# File 'lib/html_slicer/helpers/slicer.rb', line 170 def +(other) to_i + other.to_i end |
#-(other) ⇒ Object
174 175 176 |
# File 'lib/html_slicer/helpers/slicer.rb', line 174 def -(other) to_i - other.to_i end |
#<=>(other) ⇒ Object
178 179 180 |
# File 'lib/html_slicer/helpers/slicer.rb', line 178 def <=>(other) to_i <=> other.to_i end |
#current? ⇒ Boolean
current slice or not
118 119 120 |
# File 'lib/html_slicer/helpers/slicer.rb', line 118 def current? @slice == @options[:current_slice] end |
#first? ⇒ Boolean
the first slice or not
123 124 125 |
# File 'lib/html_slicer/helpers/slicer.rb', line 123 def first? @slice == 1 end |
#inside_window? ⇒ Boolean
inside the inner window or not
153 154 155 |
# File 'lib/html_slicer/helpers/slicer.rb', line 153 def inside_window? (@options[:current_slice] - @slice).abs <= @options[:window] end |
#last? ⇒ Boolean
the last slice or not
128 129 130 |
# File 'lib/html_slicer/helpers/slicer.rb', line 128 def last? @slice == @options[:slice_number] end |
#left_outer? ⇒ Boolean
within the left outer window or not
143 144 145 |
# File 'lib/html_slicer/helpers/slicer.rb', line 143 def left_outer? @slice <= @options[:left] end |
#next? ⇒ Boolean
the next slice or not
138 139 140 |
# File 'lib/html_slicer/helpers/slicer.rb', line 138 def next? @slice == @options[:current_slice] + 1 end |
#number ⇒ Object
the slice number
113 114 115 |
# File 'lib/html_slicer/helpers/slicer.rb', line 113 def number @slice end |
#prev? ⇒ Boolean
the previous slice or not
133 134 135 |
# File 'lib/html_slicer/helpers/slicer.rb', line 133 def prev? @slice == @options[:current_slice] - 1 end |
#right_outer? ⇒ Boolean
within the right outer window or not
148 149 150 |
# File 'lib/html_slicer/helpers/slicer.rb', line 148 def right_outer? @options[:slice_number] - @slice < @options[:right] end |
#to_i ⇒ Object
162 163 164 |
# File 'lib/html_slicer/helpers/slicer.rb', line 162 def to_i number end |
#to_s ⇒ Object
166 167 168 |
# File 'lib/html_slicer/helpers/slicer.rb', line 166 def to_s number.to_s end |
#was_truncated? ⇒ Boolean
The last rendered tag was “truncated” or not
158 159 160 |
# File 'lib/html_slicer/helpers/slicer.rb', line 158 def was_truncated? @last.is_a? Gap end |