Class: Guard::Copy::Target
- Inherits:
-
Object
- Object
- Guard::Copy::Target
- Defined in:
- lib/guard/copy/target.rb
Instance Attribute Summary collapse
-
#glob ⇒ Object
readonly
Returns the value of attribute glob.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#absolute? ⇒ Boolean
True if the pattern is an absolute path.
-
#initialize(pattern, options = {}) ⇒ Target
constructor
Initialize a new target.
-
#resolve! ⇒ Object
Resolve the target into one or more paths.
Constructor Details
#initialize(pattern, options = {}) ⇒ Target
Initialize a new target
12 13 14 15 16 17 18 19 |
# File 'lib/guard/copy/target.rb', line 12 def initialize(pattern, = {}) raise ArgumentError, 'pattern cannot be nil' unless pattern raise ArgumentError, 'pattern cannot be empty' if pattern.empty? @pattern = pattern @glob = [:glob] || :all @expand_pattern = ![:mkpath] @paths = [] end |
Instance Attribute Details
#glob ⇒ Object (readonly)
Returns the value of attribute glob.
5 6 7 |
# File 'lib/guard/copy/target.rb', line 5 def glob @glob end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
5 6 7 |
# File 'lib/guard/copy/target.rb', line 5 def paths @paths end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
5 6 7 |
# File 'lib/guard/copy/target.rb', line 5 def pattern @pattern end |
Instance Method Details
#absolute? ⇒ Boolean
Returns true if the pattern is an absolute path.
33 34 35 |
# File 'lib/guard/copy/target.rb', line 33 def absolute? pattern.start_with?('/') end |
#resolve! ⇒ Object
Resolve the target into one or more paths
22 23 24 25 26 27 28 29 30 |
# File 'lib/guard/copy/target.rb', line 22 def resolve! paths.clear if else paths << pattern end warn_if_empty end |