Class: Kilza::Property

Inherits:
Object
  • Object
show all
Defined in:
lib/kilza/property.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, is_array, is_key) ⇒ Property

Returns a new instance of Property.



10
11
12
13
14
15
16
# File 'lib/kilza/property.rb', line 10

def initialize(name, type, is_array, is_key)
  @name = Kilza::normalize(name)
  @original_name = name
  @type = type
  @is_array = is_array
  @is_key = is_key
end

Instance Attribute Details

#is_arrayObject

Returns the value of attribute is_array.



7
8
9
# File 'lib/kilza/property.rb', line 7

def is_array
  @is_array
end

#is_keyObject

Returns the value of attribute is_key.



8
9
10
# File 'lib/kilza/property.rb', line 8

def is_key
  @is_key
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/kilza/property.rb', line 3

def name
  @name
end

#original_nameObject

Returns the value of attribute original_name.



4
5
6
# File 'lib/kilza/property.rb', line 4

def original_name
  @original_name
end

#paramsObject

Returns the value of attribute params.



6
7
8
# File 'lib/kilza/property.rb', line 6

def params
  @params
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/kilza/property.rb', line 5

def type
  @type
end

Instance Method Details

#is_array?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/kilza/property.rb', line 18

def is_array?
  @is_array
end

#is_boolean?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/kilza/property.rb', line 30

def is_boolean?
  @type == 'trueclass' or @type == 'falseclass'
end

#is_fixnum?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/kilza/property.rb', line 26

def is_fixnum?
  @type == 'fixnum'
end

#is_float?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/kilza/property.rb', line 34

def is_float?
  @type == 'float'
end

#is_nil?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/kilza/property.rb', line 38

def is_nil?
  @type == 'nilclass'
end

#is_object?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/kilza/property.rb', line 22

def is_object?
  @type == 'object' or @type == @name.capitalize
end

#to_hashObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/kilza/property.rb', line 42

def to_hash
  hash = {
    :name => @name,
    :original_name => @original_name,
    :type => @type,
    :params => @params,
    :is_array? => @is_array,
    :is_object? => is_object?,
    :is_fixnum? => is_fixnum?,
    :is_boolean? => is_boolean?,
    :is_float? => is_float?,
    :is_nil? => is_nil?
  }
  hash
end