Class: Guilded::Component

Inherits:
Object
  • Object
show all
Defined in:
lib/guilded/component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Component

Returns a new instance of Component.



12
13
14
15
16
17
18
19
# File 'lib/guilded/component.rb', line 12

def initialize( name, options={} )
  @name           = name
  @has_javascript = options.fetch( :has_javascript, true )

  options.delete :has_javascript

  @options        = options.stringify_keys
end

Instance Attribute Details

#has_javascriptObject (readonly)

Returns the value of attribute has_javascript.



8
9
10
# File 'lib/guilded/component.rb', line 8

def has_javascript
  @has_javascript
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/guilded/component.rb', line 8

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/guilded/component.rb', line 8

def options
  @options
end

Instance Method Details

#javascript?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/guilded/component.rb', line 27

def javascript?
  has_javascript
end

#javascript_initializerObject



21
22
23
24
25
# File 'lib/guilded/component.rb', line 21

def javascript_initializer
  javascript? ?
    "g.init#{name.to_s.camelize}(#{options.to_json});" :
    ""
end