Class: AxlsxEnhanced::Helpers::Styles::StyleCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/axlsx_enhanced/helpers/styles/style_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(worksheet, items = []) ⇒ StyleCollection

Returns a new instance of StyleCollection.



5
6
7
8
9
10
# File 'lib/axlsx_enhanced/helpers/styles/style_collection.rb', line 5

def initialize(worksheet, items = [])
  @worksheet = worksheet
  @collection = []
      
  self.add(items)
end

Instance Method Details

#add(args) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/axlsx_enhanced/helpers/styles/style_collection.rb', line 20

def add(args)
  items = args.is_a?(Array) ? args : [args]
      
  items.each do |item|
    self.collection.push AxlsxEnhanced::Helpers::Styles::Style.new(item)
  end
end

#collectionObject



16
17
18
# File 'lib/axlsx_enhanced/helpers/styles/style_collection.rb', line 16

def collection
  return @collection
end

#find(name) ⇒ Object



28
29
30
# File 'lib/axlsx_enhanced/helpers/styles/style_collection.rb', line 28

def find(name)
  return @collection.find { |x| x.name == name.to_sym }
end

#worksheetObject



12
13
14
# File 'lib/axlsx_enhanced/helpers/styles/style_collection.rb', line 12

def worksheet
  return @worksheet
end