Class: Templet::Links::BsBtnClass

Inherits:
Struct
  • Object
show all
Includes:
Constants
Defined in:
app/helpers/templet/links/bs_btn_class.rb,
lib/generators/templet/templates/core/templet/links/bs_btn_class.rb

Overview

For Bootstrap link/button HTML classes

Constant Summary

Constants included from Constants

Constants::BS_BUTTON, Constants::BS_BUTTON_BLOCK, Constants::BS_BUTTON_DROPDOWN, Constants::BS_BUTTON_GROUP, Constants::BS_BUTTON_GROUP_JUSTIFIED, Constants::BS_BUTTON_GROUP_VERTICAL, Constants::BS_BUTTON_SIZE, Constants::BS_BUTTON_SUBMIT, Constants::BS_BUTTON_SUBMIT_SEARCH, Constants::BS_BUTTON_TOOLBAR, Constants::BS_BUTTON_TYPE, Constants::BS_COL, Constants::BS_COL_OFFSET, Constants::BS_FORM, Constants::BS_FORM_INLINE, Constants::BS_LIST_GROUP, Constants::BS_LIST_GROUP_ITEM, Constants::BS_LIST_INLINE, Constants::BS_LIST_UNSTYLED, Constants::BS_NAV, Constants::BS_NAV_PILLS, Constants::BS_NAV_PILLS_STACKED, Constants::BS_NAV_TABS, Constants::BS_PANEL, Constants::BS_PANEL_BODY, Constants::BS_PANEL_HEADING, Constants::BS_PANEL_TITLE, Constants::BS_SELECTED, Constants::BS_TABLE, Constants::BS_TOOLBAR

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sizeObject

Returns the value of attribute size

Returns:

  • (Object)

    the current value of size



5
6
7
# File 'app/helpers/templet/links/bs_btn_class.rb', line 5

def size
  @size
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



5
6
7
# File 'app/helpers/templet/links/bs_btn_class.rb', line 5

def type
  @type
end

Class Method Details

.call(html_class = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/helpers/templet/links/bs_btn_class.rb', line 24

def call(html_class=nil)
  case html_class
  when String, self
    html_class
  when Symbol
    preset html_class
  when Array
    new *html_class
  else
    new
  end
end

.preset(name = nil) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'app/helpers/templet/links/bs_btn_class.rb', line 37

def preset(name=nil)
  case name
  when :default
    new
  when :item
    Constants::BS_LIST_GROUP_ITEM
  else
    new name
  end
end

Instance Method Details

#+(suffix) ⇒ Object

Allows compatibily with an HTML class specifield in a String



17
18
19
20
21
# File 'app/helpers/templet/links/bs_btn_class.rb', line 17

def +(suffix)
  suffix = suffix.to_s

  call + (suffix.start_with?(' ') ? '' : ' ') + suffix
end

#call(type: type(), size: size()) ⇒ Object



8
9
10
11
12
# File 'app/helpers/templet/links/bs_btn_class.rb', line 8

def call(type: type(), size: size())
  "#{BS_BUTTON} " +
    "#{BS_BUTTON}-#{type or default_type} " +
    "#{BS_BUTTON}-#{size or default_size}"
end

#to_sObject



14
15
16
17
18
# File 'app/helpers/templet/links/bs_btn_class.rb', line 14

def call(type: type(), size: size())
  "#{BS_BUTTON} " +
    "#{BS_BUTTON}-#{type or default_type} " +
    "#{BS_BUTTON}-#{size or default_size}"
end