Class: Kali::Type::Quoted

Inherits:
Kali::Type show all
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

Methods inherited from Kali::Type

#decode, #encode, #parameters

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