Class: Cure::Dsl::Extraction
- Inherits:
-
Object
- Object
- Cure::Dsl::Extraction
- Defined in:
- lib/cure/dsl/extraction.rb
Instance Attribute Summary collapse
-
#named_ranges ⇒ Object
readonly
Returns the value of attribute named_ranges.
-
#sample_rows ⇒ Object
readonly
Returns the value of attribute sample_rows.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
-
#initialize ⇒ Extraction
constructor
A new instance of Extraction.
- #named_range(name:, at: -1,, headers: nil, ref_name: nil, placeholder: false, &block) ⇒ Object
- #required_named_ranges(ref_name: "_default") ⇒ Array
- #required_variables(ref_name: "_default") ⇒ Array
- #sample(rows: nil) ⇒ Object
- #variable(name:, at:, ref_name: nil) ⇒ Object
Constructor Details
#initialize ⇒ Extraction
Returns a new instance of Extraction.
12 13 14 15 |
# File 'lib/cure/dsl/extraction.rb', line 12 def initialize @named_ranges = [] @variables = [] end |
Instance Attribute Details
#named_ranges ⇒ Object (readonly)
Returns the value of attribute named_ranges.
10 11 12 |
# File 'lib/cure/dsl/extraction.rb', line 10 def named_ranges @named_ranges end |
#sample_rows ⇒ Object (readonly)
Returns the value of attribute sample_rows.
10 11 12 |
# File 'lib/cure/dsl/extraction.rb', line 10 def sample_rows @sample_rows end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
10 11 12 |
# File 'lib/cure/dsl/extraction.rb', line 10 def variables @variables end |
Instance Method Details
#named_range(name:, at: -1,, headers: nil, ref_name: nil, placeholder: false, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cure/dsl/extraction.rb', line 17 def named_range(name:, at: -1, headers: nil, ref_name: nil, placeholder: false, &block) named_range = Extract::NamedRange.new(name, at, headers: headers, ref_name: ref_name, placeholder: placeholder ) if block_given? named_range.filter.instance_eval(&block) end @named_ranges << named_range end |
#required_named_ranges(ref_name: "_default") ⇒ Array
41 42 43 44 45 46 47 |
# File 'lib/cure/dsl/extraction.rb', line 41 def required_named_ranges(ref_name: "_default") # This now needs to take support multiple files. We don't want named ranges # for different files return @named_ranges if ref_name == "default" @named_ranges.select { |nr| nr.ref_name == ref_name && nr.placeholder == false } end |
#required_variables(ref_name: "_default") ⇒ Array
51 52 53 54 55 56 57 |
# File 'lib/cure/dsl/extraction.rb', line 51 def required_variables(ref_name: "_default") # This now needs to take support multiple files. We don't want named ranges # for different files return @variables if ref_name == "_default" @variables.select { |v| v.ref_name == ref_name } end |
#sample(rows: nil) ⇒ Object
35 36 37 |
# File 'lib/cure/dsl/extraction.rb', line 35 def sample(rows: nil) @sample_rows = rows end |