Class: Encoding
Class Attribute Summary collapse
-
.default_external ⇒ Object
Returns the value of attribute default_external.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#names ⇒ Object
readonly
Returns the value of attribute names.
Class Method Summary collapse
Instance Method Summary collapse
- #ascii_compatible? ⇒ Boolean
- #bytesize ⇒ Object
- #dummy? ⇒ Boolean
-
#each_byte ⇒ Object
methods to implement per encoding.
- #getbyte ⇒ Object
-
#initialize(name, names, ascii, dummy) ⇒ Encoding
constructor
A new instance of Encoding.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, names, ascii, dummy) ⇒ Encoding
Returns a new instance of Encoding
34 35 36 37 38 39 |
# File 'opal/stdlib/encoding.rb', line 34 def initialize(name, names, ascii, dummy) @name = name @names = names @ascii = ascii @dummy = dummy end |
Class Attribute Details
.default_external ⇒ Object
Returns the value of attribute default_external
29 30 31 |
# File 'opal/stdlib/encoding.rb', line 29 def default_external @default_external end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name
32 33 34 |
# File 'opal/stdlib/encoding.rb', line 32 def name @name end |
#names ⇒ Object (readonly)
Returns the value of attribute names
32 33 34 |
# File 'opal/stdlib/encoding.rb', line 32 def names @names end |
Class Method Details
.find(name) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'opal/stdlib/encoding.rb', line 14 def self.find(name) return name if self === name constants.each {|const| encoding = const_get(const) if encoding.name == name || encoding.names.include?(name) return encoding end } raise ArgumentError, "unknown encoding name - #{name}" end |
.register(name, options = {}, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'opal/stdlib/encoding.rb', line 4 def self.register(name, = {}, &block) names = [name] + ([:aliases] || []) encoding = Class.new(self, &block). new(name, names, [:ascii] || false, [:dummy] || false) names.each {|name| const_set name.sub('-', '_'), encoding } end |
Instance Method Details
#ascii_compatible? ⇒ Boolean
41 42 43 |
# File 'opal/stdlib/encoding.rb', line 41 def ascii_compatible? @ascii end |
#bytesize ⇒ Object
66 67 68 |
# File 'opal/stdlib/encoding.rb', line 66 def bytesize(*) raise NotImplementedError end |
#each_byte ⇒ Object
methods to implement per encoding
58 59 60 |
# File 'opal/stdlib/encoding.rb', line 58 def each_byte(*) raise NotImplementedError end |
#getbyte ⇒ Object
62 63 64 |
# File 'opal/stdlib/encoding.rb', line 62 def getbyte(*) raise NotImplementedError end |
#inspect ⇒ Object
53 54 55 |
# File 'opal/stdlib/encoding.rb', line 53 def inspect "#<Encoding:#{@name}#{" (dummy)" if @dummy}>" end |
#to_s ⇒ Object
49 50 51 |
# File 'opal/stdlib/encoding.rb', line 49 def to_s @name end |