Class: Webspicy::Support::StatusRange
- Inherits:
-
Object
- Object
- Webspicy::Support::StatusRange
- Defined in:
- lib/webspicy/support/status_range.rb
Instance Attribute Summary collapse
-
#range ⇒ Object
readonly
Returns the value of attribute range.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #===(status) ⇒ Object
- #hash ⇒ Object
-
#initialize(range) ⇒ StatusRange
constructor
A new instance of StatusRange.
- #to_i ⇒ Object
- #to_int ⇒ Object
- #to_s ⇒ Object (also: #inspect)
- #to_str ⇒ Object
Constructor Details
#initialize(range) ⇒ StatusRange
Returns a new instance of StatusRange.
5 6 7 |
# File 'lib/webspicy/support/status_range.rb', line 5 def initialize(range) @range = range end |
Instance Attribute Details
#range ⇒ Object (readonly)
Returns the value of attribute range.
8 9 10 |
# File 'lib/webspicy/support/status_range.rb', line 8 def range @range end |
Class Method Details
.int(i) ⇒ Object
10 11 12 |
# File 'lib/webspicy/support/status_range.rb', line 10 def self.int(i) new(i..i) end |
.str(s) ⇒ Object
18 19 20 21 |
# File 'lib/webspicy/support/status_range.rb', line 18 def self.str(s) from = s[/^(\d)/,1].to_i * 100 new(from...from+100) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
35 36 37 |
# File 'lib/webspicy/support/status_range.rb', line 35 def ==(other) other.is_a?(StatusRange) && self.range == other.range end |
#===(status) ⇒ Object
31 32 33 |
# File 'lib/webspicy/support/status_range.rb', line 31 def ===(status) range === status end |
#hash ⇒ Object
40 41 42 |
# File 'lib/webspicy/support/status_range.rb', line 40 def hash @range.hash end |
#to_i ⇒ Object
27 28 29 |
# File 'lib/webspicy/support/status_range.rb', line 27 def to_i @range.first end |
#to_int ⇒ Object
14 15 16 |
# File 'lib/webspicy/support/status_range.rb', line 14 def to_int @range.first end |
#to_s ⇒ Object Also known as: inspect
44 45 46 47 48 49 50 |
# File 'lib/webspicy/support/status_range.rb', line 44 def to_s if @range.first == @range.last @range.first.to_s else @range.to_s end end |
#to_str ⇒ Object
23 24 25 |
# File 'lib/webspicy/support/status_range.rb', line 23 def to_str "#{@range.first/100}xx" end |