Class: Characteristics
- Inherits:
-
Object
show all
- Defined in:
- lib/characteristics.rb,
lib/characteristics/version.rb
Constant Summary
collapse
- VERSION =
"0.2.0".freeze
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Characteristics.
43
44
45
46
47
|
# File 'lib/characteristics.rb', line 43
def initialize(char)
@is_valid = char.valid_encoding?
@encoding = char.encoding
@encoding_name = @encoding.name
end
|
Instance Attribute Details
#encoding ⇒ Object
Returns the value of attribute encoding.
41
42
43
|
# File 'lib/characteristics.rb', line 41
def encoding
@encoding
end
|
Class Method Details
.create(char) ⇒ Object
37
38
39
|
# File 'lib/characteristics.rb', line 37
def self.create(char)
create_for_type(char, type_from_encoding_name(char.encoding.name))
end
|
.create_for_type(char, type) ⇒ Object
.type_from_encoding_name(encoding_name) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/characteristics.rb', line 9
def self.type_from_encoding_name(encoding_name)
case encoding_name
when "US-ASCII"
:ascii
when "ASCII-8BIT"
:binary
when /^UTF-/
:unicode
when /^ISO-8859-/, /^Windows-125/
:byte
else
raise ArgumentError, "encoding <#{encoding_name}> not supported"
end
end
|
Instance Method Details
#assigned? ⇒ Boolean
57
58
|
# File 'lib/characteristics.rb', line 57
def assigned?
end
|
#blank? ⇒ Boolean
63
64
|
# File 'lib/characteristics.rb', line 63
def blank?
end
|
#control? ⇒ Boolean
60
61
|
# File 'lib/characteristics.rb', line 60
def control?
end
|
#unicode? ⇒ Boolean
53
54
55
|
# File 'lib/characteristics.rb', line 53
def unicode?
false
end
|
#valid? ⇒ Boolean
49
50
51
|
# File 'lib/characteristics.rb', line 49
def valid?
@is_valid
end
|