Class: Cure::Extract::Variable

Inherits:
Object
  • Object
show all
Defined in:
lib/cure/extract/variable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, location, ref_name: "_default") ⇒ Variable

Returns a new instance of Variable.



8
9
10
11
12
13
# File 'lib/cure/extract/variable.rb', line 8

def initialize(name, location, ref_name: "_default")
  @name = name
  @location = [Extract::CsvLookup.position_for_letter(location),
               Extract::CsvLookup.position_for_digit(location)]
  @ref_name = ref_name
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



6
7
8
# File 'lib/cure/extract/variable.rb', line 6

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/cure/extract/variable.rb', line 6

def name
  @name
end

#ref_nameObject (readonly)

Returns the value of attribute ref_name.



6
7
8
# File 'lib/cure/extract/variable.rb', line 6

def ref_name
  @ref_name
end

Instance Method Details

#row_bounds_rangeRange

Returns:

  • (Range)


20
21
22
# File 'lib/cure/extract/variable.rb', line 20

def row_bounds_range
  @row_bounds_range ||= (@location&.last..@location&.last)
end

#row_in_bounds?(row_idx) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/cure/extract/variable.rb', line 15

def row_in_bounds?(row_idx)
  row_bounds_range.cover?(row_idx)
end