Class: Rack::CoreData::DataModel::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/core-data/data_model/attribute.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute) ⇒ Attribute

Returns a new instance of Attribute.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rack/core-data/data_model/attribute.rb', line 5

def initialize(attribute)
  raise ArgumentError unless ::Nokogiri::XML::Element === attribute

  @name = attribute['name']
  @type = attribute['attributeType']
  @identifier = attribute['elementID']
  @version_hash_modifier = attribute['versionHashModifier']

  @default_value = default_value_from_string(attribute['defaultValueString'])
  @minimum_value = range_value_from_string(attribute['minValueString'])
  @maximum_value = range_value_from_string(attribute['maxValueString'])

  @regular_expression = Regexp.new(attributes['regularExpressionString']) rescue nil

  @optional = attribute['optional'] == "YES"
  @transient = attribute['transient'] == "YES"
  @indexed = attribute['indexed'] == "YES"
  @syncable = attribute['syncable'] == "YES"
end

Instance Attribute Details

#default_valueObject (readonly)

Returns the value of attribute default_value.



3
4
5
# File 'lib/rack/core-data/data_model/attribute.rb', line 3

def default_value
  @default_value
end

#identifierObject (readonly)

Returns the value of attribute identifier.



3
4
5
# File 'lib/rack/core-data/data_model/attribute.rb', line 3

def identifier
  @identifier
end

#maximum_valueObject (readonly)

Returns the value of attribute maximum_value.



3
4
5
# File 'lib/rack/core-data/data_model/attribute.rb', line 3

def maximum_value
  @maximum_value
end

#minimum_valueObject (readonly)

Returns the value of attribute minimum_value.



3
4
5
# File 'lib/rack/core-data/data_model/attribute.rb', line 3

def minimum_value
  @minimum_value
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/rack/core-data/data_model/attribute.rb', line 3

def name
  @name
end

#regular_expressionObject (readonly)

Returns the value of attribute regular_expression.



3
4
5
# File 'lib/rack/core-data/data_model/attribute.rb', line 3

def regular_expression
  @regular_expression
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/rack/core-data/data_model/attribute.rb', line 3

def type
  @type
end

#version_hash_modifierObject (readonly)

Returns the value of attribute version_hash_modifier.



3
4
5
# File 'lib/rack/core-data/data_model/attribute.rb', line 3

def version_hash_modifier
  @version_hash_modifier
end

Instance Method Details

#to_sObject



25
26
27
# File 'lib/rack/core-data/data_model/attribute.rb', line 25

def to_s
  [@name, @type].to_s
end