Class: Ecic::Library
- Inherits:
-
Object
- Object
- Ecic::Library
- Defined in:
- lib/ecic/library.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#source_files ⇒ Object
Returns the value of attribute source_files.
Instance Method Summary collapse
- #create(name) ⇒ Object
-
#initialize(project, name = nil) ⇒ Library
constructor
A new instance of Library.
- #load_sources ⇒ Object
-
#source_file ⇒ Object
Function used by ‘source.create’ method used in src/confic/libraries.rb.
- #to_json(options = {}) ⇒ Object
- #to_str(options = {}) ⇒ Object
Constructor Details
#initialize(project, name = nil) ⇒ Library
Returns a new instance of Library.
8 9 10 11 12 |
# File 'lib/ecic/library.rb', line 8 def initialize(project, name=nil) @project = project @name = name @source_files = [] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/ecic/library.rb', line 5 def name @name end |
#source_files ⇒ Object
Returns the value of attribute source_files.
6 7 8 |
# File 'lib/ecic/library.rb', line 6 def source_files @source_files end |
Instance Method Details
#create(name) ⇒ Object
14 15 16 |
# File 'lib/ecic/library.rb', line 14 def create(name) @name = name end |
#load_sources ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ecic/library.rb', line 36 def load_sources src_file = File.join(@project.root, 'src', 'design', @name, 'sources.rb') if File.exists?(src_file) begin eval File.read(src_file) rescue Exception => exc raise "Syntax error occurred while reading #{src_file}: #{exc.}" end else raise "Could not read sources for #{name} library" end end |
#source_file ⇒ Object
Function used by ‘source.create’ method used in src/confic/libraries.rb
50 51 52 53 54 |
# File 'lib/ecic/library.rb', line 50 def source_file new_src = SourceFile.new(self) source_files << new_src new_src end |
#to_json(options = {}) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/ecic/library.rb', line 27 def to_json( = {}) incl_src_files = [:include_source_files] || false if incl_src_files str = {:name => name, :source_files => source_files}.to_json else str = {:name => name}.to_json end end |
#to_str(options = {}) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/ecic/library.rb', line 18 def to_str(={}) str = name incl_src_files = [:include_source_files] || false if incl_src_files str += "\n" + source_files.join("\n") end str end |