Class: ActiveModel::Type::Binary::Data
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activemodel/lib/active_model/type/binary.rb |
Class Method Summary
- .new(value) ⇒ Data constructor
Instance Method Summary
- #==(other)
- #hex
- #to_s (also: #to_str)
-
#to_str
Alias for #to_s.
Constructor Details
.new(value) ⇒ Data
# File 'activemodel/lib/active_model/type/binary.rb', line 41
def initialize(value) value = value.to_s value = value.b unless value.encoding == Encoding::BINARY @value = value end
Instance Method Details
#==(other)
[ GitHub ]# File 'activemodel/lib/active_model/type/binary.rb', line 56
def ==(other) other == to_s || super end
#hex
[ GitHub ]# File 'activemodel/lib/active_model/type/binary.rb', line 52
def hex @value.unpack1("H*") end
#to_s Also known as: #to_str
[ GitHub ]# File 'activemodel/lib/active_model/type/binary.rb', line 47
def to_s @value end
#to_str
Alias for #to_s.
# File 'activemodel/lib/active_model/type/binary.rb', line 50
alias_method :to_str, :to_s