Class: OoxmlParser::Sheet

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/sheet.rb

Overview

Class for parsing <sheet> tag

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ Sheet

Returns a new instance of Sheet.



15
16
17
18
# File 'lib/ooxml_parser/xlsx_parser/workbook/sheet.rb', line 15

def initialize(parent: nil)
  @state = :visible
  super
end

Instance Attribute Details

#idString (readonly)

Returns Id of sheet.

Returns:

  • (String)

    Id of sheet



13
14
15
# File 'lib/ooxml_parser/xlsx_parser/workbook/sheet.rb', line 13

def id
  @id
end

#nameString (readonly)

Returns Name of sheet.

Returns:

  • (String)

    Name of sheet



7
8
9
# File 'lib/ooxml_parser/xlsx_parser/workbook/sheet.rb', line 7

def name
  @name
end

#sheet_idInteger (readonly)

Returns SheetId of sheet.

Returns:

  • (Integer)

    SheetId of sheet



9
10
11
# File 'lib/ooxml_parser/xlsx_parser/workbook/sheet.rb', line 9

def sheet_id
  @sheet_id
end

#stateSymbol (readonly)

Returns Specifies if sheet is hidden.

Returns:

  • (Symbol)

    Specifies if sheet is hidden



11
12
13
# File 'lib/ooxml_parser/xlsx_parser/workbook/sheet.rb', line 11

def state
  @state
end

Instance Method Details

#parse(node) ⇒ Sheet

Parse Sheet data

Parameters:

  • node (Nokogiri::XML:Element)

    with Sheet data

Returns:

  • (Sheet)

    value of Sheet



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ooxml_parser/xlsx_parser/workbook/sheet.rb', line 23

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'name'
      @name = value.value.to_s
    when 'sheetId'
      @sheet_id = value.value.to_i
    when 'state'
      @state = value.value.to_sym
    when 'id'
      @id = value.value.to_s
    end
  end
  self
end