Class: Webbed::Charset
- Inherits:
-
Object
- Object
- Webbed::Charset
- Defined in:
- lib/webbed/charset.rb
Constant Summary
- ISO_8859_1 =
The canonical representation of the ISO-8859-1 charset.
Webbed::Charset.new('ISO-8859-1')
- ISO_8859_1_ALIASES =
All representations of the ISO-8859-1 charset.
[ ISO_8859_1, Webbed::Charset.new('ISO_8859-1:1987'), Webbed::Charset.new('iso-ir-100'), Webbed::Charset.new('ISO_8859-1'), Webbed::Charset.new('latin1'), Webbed::Charset.new('l1'), Webbed::Charset.new('IBM819'), Webbed::Charset.new('CP819'), Webbed::Charset.new('csISOLatin1') ]
Instance Method Summary (collapse)
-
- (Boolean) ==(other)
Determines if two charsets are equal.
-
- (0, 1) default_quality
Returns the default quality of the charset.
-
- (Charset) initialize(string)
constructor
Creates a new charset.
-
- (Boolean) iso_8859_1?
Determines if the charset is a representation of ISO-8859-1.
-
- (String) to_s
The string representation of the charset.
Constructor Details
- (Charset) initialize(string)
Creates a new charset.
6 7 8 |
# File 'lib/webbed/charset.rb', line 6 def initialize(string) @string = string end |
Instance Method Details
- (Boolean) ==(other)
Determines if two charsets are equal.
The only identifying characteristic of charsets are the string they represent. The check is case-insensitive.
22 23 24 |
# File 'lib/webbed/charset.rb', line 22 def ==(other) @string.downcase == other.to_s.downcase end |
- (0, 1) default_quality
Returns the default quality of the charset.
For ISO-8859-1, this value is 1. For everything else, it's 0.
31 32 33 |
# File 'lib/webbed/charset.rb', line 31 def default_quality iso_8859_1? ? 1 : 0 end |
- (Boolean) iso_8859_1?
Determines if the charset is a representation of ISO-8859-1.
38 39 40 |
# File 'lib/webbed/charset.rb', line 38 def iso_8859_1? ISO_8859_1_ALIASES.include?(self) end |
- (String) to_s
The string representation of the charset
11 12 13 |
# File 'lib/webbed/charset.rb', line 11 def to_s @string end |