Class: JCON::Types::SimpleType
- Defined in:
- lib/jcon/types.rb,
lib/jcon/conformance.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Type
Instance Method Summary collapse
- #contains?(value) ⇒ Boolean
-
#initialize(name, &block) ⇒ SimpleType
constructor
A new instance of SimpleType.
- #to_s ⇒ Object
Methods inherited from Type
Constructor Details
#initialize(name, &block) ⇒ SimpleType
Returns a new instance of SimpleType.
19 20 21 22 23 |
# File 'lib/jcon/types.rb', line 19 def initialize(name, &block) name = name.intern if name.is_a?(String) @name = name @test = block end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/jcon/types.rb', line 18 def name @name end |
Instance Method Details
#contains?(value) ⇒ Boolean
4 5 6 7 8 9 10 |
# File 'lib/jcon/conformance.rb', line 4 def contains?(value) if not @test and context and@context[name] return context[name].contains?(value) end raise "No definition for #{self}" unless @test @test.call(value) end |
#to_s ⇒ Object
25 |
# File 'lib/jcon/types.rb', line 25 def to_s; name.to_s; end |