Class: Ping::Size
- Inherits:
-
Object
- Object
- Ping::Size
- Defined in:
- lib/ping/size.rb
Constant Summary collapse
- Pattern =
/ (?:^|\W) # beginning of string or non-word char (?:size|points): # keyword (\d+) # point value (?= \.+[ \t\W]| # dots followed by space or non-word character \.+$| # dots at end of line [^0-9a-zA-Z_.]| # non-word character except dot $ # end of line ) /ix
Instance Attribute Summary collapse
-
#points ⇒ Object
Returns the value of attribute points.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(points) ⇒ Size
constructor
A new instance of Size.
- #to_i ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(points) ⇒ Size
24 25 26 |
# File 'lib/ping/size.rb', line 24 def initialize(points) @points = points end |
Instance Attribute Details
#points ⇒ Object
Returns the value of attribute points.
3 4 5 |
# File 'lib/ping/size.rb', line 3 def points @points end |
Class Method Details
.extract(text) ⇒ Object
19 20 21 22 |
# File 'lib/ping/size.rb', line 19 def self.extract(text) matches = text.scan(Pattern) matches.any? ? self.new(matches.last.first.to_i) : self.new(nil) end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 |
# File 'lib/ping/size.rb', line 28 def ==(other) other.to_i == to_i end |
#to_i ⇒ Object
32 33 34 |
# File 'lib/ping/size.rb', line 32 def to_i points.to_i end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/ping/size.rb', line 36 def to_s points.to_s end |