Class: ExcelTemplating::Document::DataSourceRegistry::RegistryList

Inherits:
Object
  • Object
show all
Defined in:
lib/excel_templating/document/data_source_registry/registry_list.rb

Overview

Represents a data source list used for validation of cell information

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order, symbol, title, list, inline) ⇒ RegistryList

Returns a new instance of RegistryList.

Parameters:

  • order (Integer)
  • symbol (Symbol)
  • title (String)
  • list (Array<String>|Symbol)
  • inline (TrueClass|FalseClass)


9
10
11
12
13
14
15
16
# File 'lib/excel_templating/document/data_source_registry/registry_list.rb', line 9

def initialize(order, symbol, title, list, inline)
  @title = title
  @list = list
  @inline = inline
  @order = order
  @symbol = symbol
  pre_validate!
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



18
19
20
# File 'lib/excel_templating/document/data_source_registry/registry_list.rb', line 18

def list
  @list
end

#orderObject (readonly)

Returns the value of attribute order.



18
19
20
# File 'lib/excel_templating/document/data_source_registry/registry_list.rb', line 18

def order
  @order
end

#symbolObject (readonly)

Returns the value of attribute symbol.



18
19
20
# File 'lib/excel_templating/document/data_source_registry/registry_list.rb', line 18

def symbol
  @symbol
end

#titleObject (readonly)

Returns the value of attribute title.



18
19
20
# File 'lib/excel_templating/document/data_source_registry/registry_list.rb', line 18

def title
  @title
end

Instance Method Details

#data_sheet?Boolean

Returns Is this to be rendered on the data sheet?.

Returns:

  • (Boolean)

    Is this to be rendered on the data sheet?



26
27
28
# File 'lib/excel_templating/document/data_source_registry/registry_list.rb', line 26

def data_sheet?
  !inline?
end

#inline?Boolean

Returns Is this to be rendered inline?.

Returns:

  • (Boolean)

    Is this to be rendered inline?



21
22
23
# File 'lib/excel_templating/document/data_source_registry/registry_list.rb', line 21

def inline?
  @inline
end

#items(data) ⇒ Array<String>

Returns The validation objects.

Parameters:

  • data (Hash)

    The data object from which the document is being rendered

Returns:

  • (Array<String>)

    The validation objects



32
33
34
35
36
37
38
# File 'lib/excel_templating/document/data_source_registry/registry_list.rb', line 32

def items(data)
  if list == :from_data
    data[symbol]
  else
    list
  end
end