Class: PwaManifestGenerator::Shortcut

Inherits:
Object
  • Object
show all
Defined in:
lib/pwa_manifest_generator/shortcut.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, url:, description:, icons: []) ⇒ Shortcut

Returns a new instance of Shortcut.



9
10
11
12
13
14
15
16
# File 'lib/pwa_manifest_generator/shortcut.rb', line 9

def initialize(name:, url:, description:, icons: [])
  @name = name
  @url = url
  @description = description
  @icons = icons.map do |icon|
    icon.is_a?(Icon) ? icon : Icon.new(**icon)
  end
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



7
8
9
# File 'lib/pwa_manifest_generator/shortcut.rb', line 7

def description
  @description
end

#iconsObject

Returns the value of attribute icons.



7
8
9
# File 'lib/pwa_manifest_generator/shortcut.rb', line 7

def icons
  @icons
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/pwa_manifest_generator/shortcut.rb', line 7

def name
  @name
end

#urlObject

Returns the value of attribute url.



7
8
9
# File 'lib/pwa_manifest_generator/shortcut.rb', line 7

def url
  @url
end

Instance Method Details

#to_hObject



18
19
20
21
22
23
24
25
# File 'lib/pwa_manifest_generator/shortcut.rb', line 18

def to_h
  {
    name: @name,
    url: @url,
    description: @description,
    icons: @icons.map(&:to_h)
  }
end