Module: Card::Format::ContextNames
- Included in:
- Card::Format
- Defined in:
- lib/card/format/context_names.rb
Instance Method Summary collapse
- #add_name_context(name = nil) ⇒ Object
- #context_names ⇒ Object
- #context_names_from_params ⇒ Object
- #context_names_from_parent ⇒ Object
- #context_names_to_params ⇒ Object
- #initial_context_names ⇒ Object
- #title_in_context(title = nil) ⇒ Object
Instance Method Details
#add_name_context(name = nil) ⇒ Object
29 30 31 32 |
# File 'lib/card/format/context_names.rb', line 29 def add_name_context name=nil name ||= card.name @context_names = (context_names + name.to_name.part_names).uniq end |
#context_names ⇒ Object
5 6 7 |
# File 'lib/card/format/context_names.rb', line 5 def context_names @context_names ||= initial_context_names end |
#context_names_from_params ⇒ Object
19 20 21 22 |
# File 'lib/card/format/context_names.rb', line 19 def context_names_from_params return [] unless (name_list = Card::Env.slot_opts[:name_context]) name_list.to_s.split(",").map(&:to_name) end |
#context_names_from_parent ⇒ Object
14 15 16 17 |
# File 'lib/card/format/context_names.rb', line 14 def context_names_from_parent part_keys = @card.name.part_names.map(&:key) parent.context_names.reject { |n| !part_keys.include? n.key } end |
#context_names_to_params ⇒ Object
24 25 26 27 |
# File 'lib/card/format/context_names.rb', line 24 def context_names_to_params return if context_names.empty? context_names.join(",") end |
#initial_context_names ⇒ Object
9 10 11 12 |
# File 'lib/card/format/context_names.rb', line 9 def initial_context_names @initial_context_names ||= parent ? context_names_from_parent : context_names_from_params end |
#title_in_context(title = nil) ⇒ Object
34 35 36 37 |
# File 'lib/card/format/context_names.rb', line 34 def title_in_context title=nil title = title ? title.to_name.absolute_name(card.name) : card.name title.from *context_names end |