Class: Comet::DSL::Native::Source
- Inherits:
-
Object
- Object
- Comet::DSL::Native::Source
- Includes:
- Helpers
- Defined in:
- lib/comet/dsl/native/source.rb
Instance Attribute Summary collapse
-
#imports ⇒ Object
readonly
Returns the value of attribute imports.
Instance Method Summary collapse
- #files ⇒ Object
- #import(pattern) ⇒ Object
-
#initialize(**_, &block) ⇒ Source
constructor
A new instance of Source.
- #language ⇒ Object
- #native? ⇒ Boolean
- #to_s ⇒ Object
- #validate! ⇒ Object
Methods included from Helpers
Constructor Details
#initialize(**_, &block) ⇒ Source
Returns a new instance of Source.
12 13 14 15 16 |
# File 'lib/comet/dsl/native/source.rb', line 12 def initialize(**_, &block) @imports = [] instance_exec(&block) if block_given? end |
Instance Attribute Details
#imports ⇒ Object (readonly)
Returns the value of attribute imports.
22 23 24 |
# File 'lib/comet/dsl/native/source.rb', line 22 def imports @imports end |
Instance Method Details
#files ⇒ Object
32 33 34 35 36 |
# File 'lib/comet/dsl/native/source.rb', line 32 def files @imports.flat_map do |pattern| Dir.glob pattern end.uniq end |
#import(pattern) ⇒ Object
8 9 10 |
# File 'lib/comet/dsl/native/source.rb', line 8 def import(pattern) @imports.push pattern end |
#language ⇒ Object
24 25 26 |
# File 'lib/comet/dsl/native/source.rb', line 24 def language :native end |
#native? ⇒ Boolean
28 29 30 |
# File 'lib/comet/dsl/native/source.rb', line 28 def native? true end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/comet/dsl/native/source.rb', line 18 def to_s 'native source' end |
#validate! ⇒ Object
38 39 40 |
# File 'lib/comet/dsl/native/source.rb', line 38 def validate! raise "#{self} references no source files" if @imports.empty? end |