Class: String19::Wrapper
- Inherits:
-
BlankSlate
- Object
- BlankSlate
- String19::Wrapper
- Defined in:
- lib/string19.rb
Instance Attribute Summary collapse
-
#chars ⇒ Object
readonly
Returns the value of attribute chars.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #bytes ⇒ Object
- #bytesize ⇒ Object
- #class ⇒ Object
- #encoding ⇒ Object
- #index(what, offset = 0) ⇒ Object
-
#initialize(wrapped) ⇒ Wrapper
constructor
A new instance of Wrapper.
- #is_a?(klass) ⇒ Boolean
- #to_s ⇒ Object
- #to_s18 ⇒ Object
- #valid_encoding? ⇒ Boolean
Constructor Details
#initialize(wrapped) ⇒ Wrapper
Returns a new instance of Wrapper.
17 18 19 |
# File 'lib/string19.rb', line 17 def initialize(wrapped) @chars = wrapped.scan(/./m) end |
Instance Attribute Details
#chars ⇒ Object (readonly)
Returns the value of attribute chars.
15 16 17 |
# File 'lib/string19.rb', line 15 def chars @chars end |
Instance Method Details
#==(other) ⇒ Object
45 46 47 48 |
# File 'lib/string19.rb', line 45 def ==(other) other = other.to_s18 if other.is_a?(String19::Wrapper) other.is_a?(String) and to_s18 == other end |
#bytes ⇒ Object
29 30 31 |
# File 'lib/string19.rb', line 29 def bytes to_s18.bytes end |
#bytesize ⇒ Object
25 26 27 |
# File 'lib/string19.rb', line 25 def bytesize to_s18.size end |
#class ⇒ Object
37 38 39 |
# File 'lib/string19.rb', line 37 def class String end |
#encoding ⇒ Object
33 34 35 |
# File 'lib/string19.rb', line 33 def encoding Encoding.new('UTF-8') end |
#index(what, offset = 0) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/string19.rb', line 62 def index(what, offset=0) s = to_s18 offset = self[0...offset].to_s18.size return unless found = s.index(what, offset) String19(s[0...found]).size end |
#is_a?(klass) ⇒ Boolean
41 42 43 |
# File 'lib/string19.rb', line 41 def is_a?(klass) [String19::Wrapper, String, Object].include?(klass) end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/string19.rb', line 50 def to_s self end |
#to_s18 ⇒ Object
54 55 56 |
# File 'lib/string19.rb', line 54 def to_s18 @chars.to_s end |
#valid_encoding? ⇒ Boolean
58 59 60 |
# File 'lib/string19.rb', line 58 def valid_encoding? true # i hope so :P end |