Class: Ken::Type

Inherits:
Object
  • Object
show all
Includes:
Extlib::Assertions
Defined in:
lib/ken/type.rb

Instance Method Summary (collapse)

Constructor Details

- (Type) initialize(data)

initializes a resource using a json result



7
8
9
10
# File 'lib/ken/type.rb', line 7

def initialize(data)
  assert_kind_of 'data', data, Hash
  @data = data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(sym)

delegate to property_get



41
42
43
# File 'lib/ken/type.rb', line 41

def method_missing sym
  property_get(sym.to_s)
end

Instance Method Details

- (Object) id

type id



20
21
22
# File 'lib/ken/type.rb', line 20

def id
  @data["id"]
end

- (Object) inspect



36
37
38
# File 'lib/ken/type.rb', line 36

def inspect
  result = "#<Type id=\"#{id}\" name=\"#{name || "nil"}\">"
end

- (Object) name

type name



26
27
28
# File 'lib/ken/type.rb', line 26

def name
  @data["name"]
end

- (Object) properties

access property info



14
15
16
# File 'lib/ken/type.rb', line 14

def properties
  @properties ||= Ken::Collection.new(@data["properties"].map { |property| Ken::Property.new(property, self) })
end

- (Object) to_s



31
32
33
# File 'lib/ken/type.rb', line 31

def to_s
  name || id || ""
end