Class: CSquare::Generator::Type
- Inherits:
-
Object
- Object
- CSquare::Generator::Type
- Defined in:
- lib/csquare/generator/type.rb
Instance Attribute Summary collapse
-
#blueprint ⇒ Object
readonly
Returns the value of attribute blueprint.
-
#ctype ⇒ Object
readonly
Returns the value of attribute ctype.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#long_id ⇒ Object
readonly
Returns the value of attribute long_id.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
Instance Method Summary collapse
-
#ctype_keys ⇒ Object
Same as type_keys but returns just the ctype field.
- #generator ⇒ Object
-
#initialize(blueprint_obj, id, ctype, options) ⇒ Type
constructor
A new instance of Type.
- #inspect ⇒ Object
- #long ⇒ Object
-
#type_keys ⇒ Object
Returns the @keys hash but with a Type in the value instead of a Type id.
Constructor Details
#initialize(blueprint_obj, id, ctype, options) ⇒ Type
Returns a new instance of Type.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/csquare/generator/type.rb', line 2 def initialize blueprint_obj, id, ctype, @blueprint = blueprint_obj @id = id @ctype = ctype @long_id = .delete(:long) @min = .delete(:min) @max = .delete(:max) @keys = begin k = {} all_types = @blueprint.generator.types .each_pair do |typename, type_id| k[typename] = type_id k["LONG_#{typename}"] = all_types[type_id].long_id end k end end |
Instance Attribute Details
#blueprint ⇒ Object (readonly)
Returns the value of attribute blueprint.
21 22 23 |
# File 'lib/csquare/generator/type.rb', line 21 def blueprint @blueprint end |
#ctype ⇒ Object (readonly)
Returns the value of attribute ctype.
21 22 23 |
# File 'lib/csquare/generator/type.rb', line 21 def ctype @ctype end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
21 22 23 |
# File 'lib/csquare/generator/type.rb', line 21 def id @id end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
21 22 23 |
# File 'lib/csquare/generator/type.rb', line 21 def keys @keys end |
#long_id ⇒ Object (readonly)
Returns the value of attribute long_id.
21 22 23 |
# File 'lib/csquare/generator/type.rb', line 21 def long_id @long_id end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
21 22 23 |
# File 'lib/csquare/generator/type.rb', line 21 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
21 22 23 |
# File 'lib/csquare/generator/type.rb', line 21 def min @min end |
Instance Method Details
#ctype_keys ⇒ Object
Same as type_keys but returns just the ctype field
53 54 55 56 57 58 59 60 |
# File 'lib/csquare/generator/type.rb', line 53 def ctype_keys h = {} type_keys.each_pair do |typename, type| h[typename] = type.ctype h["LONG_#{typename}"] = type.long.ctype unless type.long.nil? end h end |
#generator ⇒ Object
30 31 32 |
# File 'lib/csquare/generator/type.rb', line 30 def generator @blueprint.generator end |
#inspect ⇒ Object
23 24 25 26 27 28 |
# File 'lib/csquare/generator/type.rb', line 23 def inspect obj_id = "0x#{(self.object_id << 1).to_s(16)}" min_part = " min=#{@min.inspect}" unless @min.nil? max_part = " max=#{@max.inspect}" unless @max.nil? "#<#{self.class.to_s}:#{obj_id} #{@id.inspect}=>#{@blueprint.id.inspect} ctype=#{@ctype.inspect} long_id=#{@long_id.inspect} keys=#{@keys.inspect}#{min_part.to_s}#{max_part.to_s}>" end |
#long ⇒ Object
38 39 40 |
# File 'lib/csquare/generator/type.rb', line 38 def long @blueprint.types[long_id] end |
#type_keys ⇒ Object
Returns the @keys hash but with a Type in the value instead of a Type id
43 44 45 46 47 48 49 50 |
# File 'lib/csquare/generator/type.rb', line 43 def type_keys h = {} @keys.each_pair do |typename, type_id| h[typename] = generator.types[type_id] h["LONG_#{typename}"] = h[typename].long unless h[typename].long.nil? end h end |