Class: Twitter::TwitterText::WeightedRange
- Inherits:
-
Object
- Object
- Twitter::TwitterText::WeightedRange
- Defined in:
- lib/twitter-text/weighted_range.rb
Instance Attribute Summary collapse
-
#end ⇒ Object
readonly
Returns the value of attribute end.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
- #contains?(code_point) ⇒ Boolean
-
#initialize(range = {}) ⇒ WeightedRange
constructor
A new instance of WeightedRange.
Constructor Details
#initialize(range = {}) ⇒ WeightedRange
Returns a new instance of WeightedRange.
12 13 14 15 16 17 |
# File 'lib/twitter-text/weighted_range.rb', line 12 def initialize(range = {}) raise ArgumentError.new("Invalid range") unless [:start, :end, :weight].all? { |key| range.key?(key) && range[key].is_a?(Integer) } @start = range[:start] @end = range[:end] @weight = range[:weight] end |
Instance Attribute Details
#end ⇒ Object (readonly)
Returns the value of attribute end.
10 11 12 |
# File 'lib/twitter-text/weighted_range.rb', line 10 def end @end end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
10 11 12 |
# File 'lib/twitter-text/weighted_range.rb', line 10 def start @start end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
10 11 12 |
# File 'lib/twitter-text/weighted_range.rb', line 10 def weight @weight end |
Instance Method Details
#contains?(code_point) ⇒ Boolean
19 20 21 |
# File 'lib/twitter-text/weighted_range.rb', line 19 def contains?(code_point) code_point >= @start && code_point <= @end end |