Class: LiquidXlsx::Validation::VariableUse

Inherits:
Struct
  • Object
show all
Defined in:
lib/liquid_xlsx/validation/usage.rb

Overview

One variable reference found in a template fragment.

segments is the lookup chain after the root: invoice.items.first.name becomes root "invoice" with segments ["items", "first", "name"].

truncated marks a path the host application must not check past its last segment: a dynamic lookup (items[idx].name) hides what comes next, and reporting "no such field" for it would be a false alarm.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#rootObject

Returns the value of attribute root

Returns:

  • (Object)

    the current value of root



13
14
15
# File 'lib/liquid_xlsx/validation/usage.rb', line 13

def root
  @root
end

#segmentsObject

Returns the value of attribute segments

Returns:

  • (Object)

    the current value of segments



13
14
15
# File 'lib/liquid_xlsx/validation/usage.rb', line 13

def segments
  @segments
end

#truncatedObject

Returns the value of attribute truncated

Returns:

  • (Object)

    the current value of truncated



13
14
15
# File 'lib/liquid_xlsx/validation/usage.rb', line 13

def truncated
  @truncated
end

Instance Method Details

#pathObject



14
15
16
# File 'lib/liquid_xlsx/validation/usage.rb', line 14

def path
  ([root] + Array(segments)).join(".")
end

#to_hObject



22
23
24
# File 'lib/liquid_xlsx/validation/usage.rb', line 22

def to_h
  { root: root, segments: Array(segments), truncated: truncated?, path: path }
end

#truncated?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/liquid_xlsx/validation/usage.rb', line 18

def truncated?
  truncated ? true : false
end