Class: Fauve::Scheme::Section

Inherits:
Object
  • Object
show all
Defined in:
lib/fauve/scheme/section.rb

Overview

Representation of a section key as part of a wider scheme. Holds a section name, which points to a top-level key within a colour scheme. Takes a section name (string)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Section

Returns a new instance of Section.



13
14
15
16
# File 'lib/fauve/scheme/section.rb', line 13

def initialize(name)
  @name       = name.to_s
  @colour_map = ColourMap.instance
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/fauve/scheme/section.rb', line 11

def name
  @name
end

Instance Method Details

#to_hObject



18
19
20
21
# File 'lib/fauve/scheme/section.rb', line 18

def to_h
  return colour_map.map[name] if section_exists?
  raise Fauve::UndefinedSectionError.new('Section is not referenced in config')
end