Class: Range
- Defined in:
- lib/primitive_wrapper.rb,
lib/primitive_wrapper.rb
Overview
if it makes sense, add methods here
Instance Method Summary collapse
- #element_class ⇒ Object
- #reorder ⇒ Object
- #reverse ⇒ Object
- #reversed? ⇒ Boolean
- #simple? ⇒ Boolean
- #simplify ⇒ Object
- #to_xr ⇒ Object
- #~ ⇒ Object
Instance Method Details
#element_class ⇒ Object
113 114 115 |
# File 'lib/primitive_wrapper.rb', line 113 def element_class return first.class end |
#reorder ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/primitive_wrapper.rb', line 96 def reorder if exclude_end? last < first ? reverse : (first...last) else last < first ? reverse : (first..last) end end |
#reverse ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/primitive_wrapper.rb', line 85 def reverse if exclude_end? if (first==last) (last...first) else ((last.pred)..first) end else (last..first) end end |
#reversed? ⇒ Boolean
79 80 81 |
# File 'lib/primitive_wrapper.rb', line 79 def reversed? first > last end |
#simple? ⇒ Boolean
116 117 118 119 120 121 122 |
# File 'lib/primitive_wrapper.rb', line 116 def simple? return true if first.type_of? Integer if first.type_of? String return true if first.length==1 end false end |
#simplify ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/primitive_wrapper.rb', line 106 def simplify if exclude_end? return (first...last) if first==last return (first..last.pred) end return (first..last) end |
#~ ⇒ Object
67 68 69 |
# File 'lib/primitive_wrapper.rb', line 67 def ~ self end |