Class: Maglove::Widgets::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Hamloft::Helpers
Defined in:
lib/maglove/widgets/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, scope) ⇒ Base

Returns a new instance of Base.



17
18
19
20
# File 'lib/maglove/widgets/base.rb', line 17

def initialize(options, scope)
  @options = defaults.merge(options)
  @scope = scope
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/maglove/widgets/base.rb', line 6

def options
  @options
end

#scopeObject (readonly)

Returns the value of attribute scope.



6
7
8
# File 'lib/maglove/widgets/base.rb', line 6

def scope
  @scope
end

Instance Method Details

#defaultsObject



13
14
15
# File 'lib/maglove/widgets/base.rb', line 13

def defaults
  {}
end

#identifierObject



9
10
11
# File 'lib/maglove/widgets/base.rb', line 9

def identifier
  "base"
end

#widget_optionsObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/maglove/widgets/base.rb', line 22

def widget_options
  attributes = { widget: true }
  @options.each do |key, value|
    attributes[key.to_s.dasherize.to_s] = value
  end
  if attributes["padding"]
    attributes["padding"] = attributes["padding"].join(" ")
  else
    attributes["padding"] = "0 0 0 0"
  end
  attributes
end