Module: Card::Set::Abstract::Pointer::OptionsApi::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
tmpsets/set/mod008-pointer/abstract/02_pointer/options_api.rb

Instance Method Summary collapse

Instance Method Details

#option_description(option_type, option_name) ⇒ Object

Parameters:

  • option_type (String)

    "checkbox" or "radio"



80
81
82
83
# File 'tmpsets/set/mod008-pointer/abstract/02_pointer/options_api.rb', line 80

def option_description option_type, option_name
  return "" unless (description = option_description_core(option_name))
  %(<div class="#{option_type}-option-description">#{description}</div>)
end

#option_description_core(option) ⇒ Object



85
86
87
88
89
90
# File 'tmpsets/set/mod008-pointer/abstract/02_pointer/options_api.rb', line 85

def option_description_core option
  # DISCUSS: "options label" is an obscure rule. still support?
  desc_name = card.rule(:options_label) || "description"
  return unless (desc_card = Card[option, desc_name])
  nest desc_card, { view: :core }, nest_mode: :normal
end

#option_label(option_name, id) ⇒ Object



71
72
73
# File 'tmpsets/set/mod008-pointer/abstract/02_pointer/options_api.rb', line 71

def option_label option_name, id
  %(<label for="#{id}">#{option_label_text option_name}</label>)
end

#option_label_text(option_name) ⇒ Object



75
76
77
# File 'tmpsets/set/mod008-pointer/abstract/02_pointer/options_api.rb', line 75

def option_label_text option_name
  Card.fetch(option_name)&.label || option_name
end