Class: Kali::Type::Quoted
- Inherits:
-
Kali::Type
- Object
- Kali::Type
- Kali::Type::Quoted
- Defined in:
- lib/kali/type/quoted.rb
Overview
Meta-type that just wraps a different type in double quote characters when encoding it, or takes out the quotes when decoding it.
Instance Method Summary collapse
- #decode!(string) ⇒ Object
- #encode!(object) ⇒ Object
-
#initialize(type, restriction = nil) ⇒ Quoted
constructor
A new instance of Quoted.
Methods inherited from Kali::Type
Constructor Details
#initialize(type, restriction = nil) ⇒ Quoted
Returns a new instance of Quoted.
5 6 7 8 |
# File 'lib/kali/type/quoted.rb', line 5 def initialize(type, restriction = nil) super(restriction) @type = type end |
Instance Method Details
#decode!(string) ⇒ Object
14 15 16 |
# File 'lib/kali/type/quoted.rb', line 14 def decode!(string) @type.decode(string.gsub(/^"|"$/, "")) end |
#encode!(object) ⇒ Object
10 11 12 |
# File 'lib/kali/type/quoted.rb', line 10 def encode!(object) %Q("#{@type.encode(object)}") end |