Module: Kilza::Class
- Included in:
- Java::Class, Objc::Class
- Defined in:
- lib/kilza/class.rb
Overview
Represents one single object class
Instance Attribute Summary collapse
-
#imports ⇒ Object
Array with all class dependecies Specific for each language.
-
#name ⇒ Object
Class name.
-
#properties ⇒ Object
Array with all class properties.
Instance Method Summary collapse
-
#code(lang, file_name) ⇒ Kilza::Source
Returns the #Source object of this Class.
-
#initialize(name) ⇒ Object
Initializes a Class object.
-
#push(property) ⇒ Object
Adds a new property.
- #sources ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#imports ⇒ Object
Array with all class dependecies Specific for each language
9 10 11 |
# File 'lib/kilza/class.rb', line 9 def imports @imports end |
#name ⇒ Object
Class name
5 6 7 |
# File 'lib/kilza/class.rb', line 5 def name @name end |
#properties ⇒ Object
Array with all class properties
12 13 14 |
# File 'lib/kilza/class.rb', line 12 def properties @properties end |
Instance Method Details
#code(lang, file_name) ⇒ Kilza::Source
Returns the #Source object of this Class.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/kilza/class.rb', line 46 def code(lang, file_name) cur_path = File.(__FILE__) erb_path = File.join(File.dirname(cur_path), 'language', lang) path = File.join(erb_path, file_name + '.erb') eruby = Erubis::Eruby.new(File.read(path)) s = Kilza::Source.new s.source = eruby.result(binding) s.file_name = @name.capitalize + '.' + file_name s end |
#initialize(name) ⇒ Object
Initializes a Class object
17 18 19 20 21 |
# File 'lib/kilza/class.rb', line 17 def initialize(name) @name = Kilza.normalize(name).capitalize @properties = [] @imports = [] end |
#push(property) ⇒ Object
Adds a new property
26 27 28 29 30 31 32 33 34 |
# File 'lib/kilza/class.rb', line 26 def push(property) index = @properties.index(property) if !index.nil? current = @properties[index] @properties[index] = update(current, property) else @properties.push(property) end end |
#sources ⇒ Object
36 37 38 |
# File 'lib/kilza/class.rb', line 36 def sources fail 'It should be implemented' end |
#to_s ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/kilza/class.rb', line 59 def to_s properties = [] @properties.each { |p| properties.push(p.to_s) } { name: @name, imports: @imports, properties: properties }.to_s end |