Class: Val::Key::Instance

Inherits:
Object show all
Defined in:
lib/val.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, it) ⇒ Instance

Returns a new instance of Instance.



188
189
190
191
192
193
194
195
196
# File 'lib/val.rb', line 188

def initialize key, it
  @name, @type = key.name, key.type
  @value = it[@name]
    
  @ok = @type === @value
rescue
  @error = $!
  @ok = false
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



186
187
188
# File 'lib/val.rb', line 186

def error
  @error
end

#nameObject (readonly)

Returns the value of attribute name.



186
187
188
# File 'lib/val.rb', line 186

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



186
187
188
# File 'lib/val.rb', line 186

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



186
187
188
# File 'lib/val.rb', line 186

def value
  @value
end

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)


198
199
200
# File 'lib/val.rb', line 198

def ok?
  @ok
end