Class: Mingle::MingleString
- Inherits:
-
MingleValue
- Object
- BitGirderClass
- MingleValue
- Mingle::MingleString
- Extended by:
- Forwardable
- Includes:
- Comparable
- Defined in:
- lib/mingle.rb
Overview
Note: it’s important that this class be defined before things like MingleNamespace, MingleIdentifier, etc, which register parse handlers for values of type MingleString.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(str) ⇒ MingleString
constructor
A new instance of MingleString.
- #inspect ⇒ Object
- #to_i ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(str) ⇒ MingleString
Returns a new instance of MingleString.
38 39 40 |
# File 'lib/mingle.rb', line 38 def initialize( str ) @str = not_nil( str, "str" ).to_s.dup end |
Instance Method Details
#<=>(other) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/mingle.rb', line 43 def <=>( other ) if other.class == self.class @str <=> other.str else raise TypeError, "Not a #{self.class}: #{other.class}" end end |
#==(other) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/mingle.rb', line 63 def ==( other ) return true if other.equal?( self ) return false unless other.is_a?( MingleString ) other_str = other.instance_variable_get( :@str ) @str == other_str end |
#eql?(other) ⇒ Boolean
73 74 75 |
# File 'lib/mingle.rb', line 73 def eql?( other ) self == other end |
#hash ⇒ Object
78 79 80 |
# File 'lib/mingle.rb', line 78 def hash @str.hash end |
#inspect ⇒ Object
58 59 60 |
# File 'lib/mingle.rb', line 58 def inspect to_s.inspect end |
#to_i ⇒ Object
83 84 85 |
# File 'lib/mingle.rb', line 83 def to_i @str.to_i end |
#to_s ⇒ Object
53 54 55 |
# File 'lib/mingle.rb', line 53 def to_s @str.to_s end |