Class: Dato::Local::FieldType::Theme

Inherits:
Object
  • Object
show all
Defined in:
lib/dato/local/field_type/theme.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logo, primary_color, dark_color, light_color, accent_color, repo) ⇒ Theme

Returns a new instance of Theme.



20
21
22
23
24
25
26
27
# File 'lib/dato/local/field_type/theme.rb', line 20

def initialize(, primary_color, dark_color, light_color, accent_color, repo)
  @logo = 
  @primary_color = primary_color
  @dark_color = dark_color
  @light_color = light_color
  @accent_color = accent_color
  @repo = repo
end

Instance Attribute Details

#accent_colorObject (readonly)

Returns the value of attribute accent_color.



7
8
9
# File 'lib/dato/local/field_type/theme.rb', line 7

def accent_color
  @accent_color
end

#dark_colorObject (readonly)

Returns the value of attribute dark_color.



7
8
9
# File 'lib/dato/local/field_type/theme.rb', line 7

def dark_color
  @dark_color
end

#light_colorObject (readonly)

Returns the value of attribute light_color.



7
8
9
# File 'lib/dato/local/field_type/theme.rb', line 7

def light_color
  @light_color
end

#primary_colorObject (readonly)

Returns the value of attribute primary_color.



7
8
9
# File 'lib/dato/local/field_type/theme.rb', line 7

def primary_color
  @primary_color
end

Class Method Details

.parse(value, repo) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/dato/local/field_type/theme.rb', line 9

def self.parse(value, repo)
  value && new(
    value[:logo],
    value[:primary_color],
    value[:dark_color],
    value[:light_color],
    value[:accent_color],
    repo
  )
end

Instance Method Details

#logoObject



29
30
31
# File 'lib/dato/local/field_type/theme.rb', line 29

def 
  @logo && UploadId.parse(@logo, @repo)
end

#to_hash(*args) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/dato/local/field_type/theme.rb', line 33

def to_hash(*args)
  {
    primary_color: primary_color,
    dark_color: dark_color,
    light_color: light_color,
    accent_color: accent_color,
    logo:  && .to_hash(*args)
  }
end