class SktlToLiquid::Type
Constants
- FILTERS
- OPERATORS
Attributes
segment[R]
Public Class Methods
new(segment)
click to toggle source
# File lib/sktl_to_liquid/type.rb, line 7 def initialize(segment) @segment = segment end
Public Instance Methods
to_sym()
click to toggle source
# File lib/sktl_to_liquid/type.rb, line 11 def to_sym type = segment.keys.first if type == :chain && loop_each_segment? :loop elsif type == :call_or_variable && else_segment? :else elsif type == :call && display_search_form_segment? :display_search_form elsif type == :call && partial_segment? :partial elsif type == :call && enrolled_in_segment? :enrolled_in? elsif type == :call && access_course_segment? :access_course? elsif type == :call && pluralize_segment? :pluralize elsif type == :chain && app_segment? :app elsif type == :call && learning_path_item_segment? :learning_path_item elsif type == :call && filter_segment? :filter elsif type == :call_or_variable && filter_segment? :filter else type end end
Private Instance Methods
access_course_segment?()
click to toggle source
# File lib/sktl_to_liquid/type.rb, line 69 def access_course_segment? [ :access_course? ].include?(segment.dig(:call, :name).to_sym) end
app_segment?()
click to toggle source
# File lib/sktl_to_liquid/type.rb, line 57 def app_segment? segment[:chain].any? { |s| s.dig(:call, :name)&.to_sym == :app } end
display_search_form_segment?()
click to toggle source
# File lib/sktl_to_liquid/type.rb, line 83 def display_search_form_segment? return false if segment.dig(:call, :name).to_sym != :if [ :display_search_form, :display_catalog_search_form ].include?(segment.dig(:call, :args, :call_or_variable, :name)&.to_sym) end
else_segment?()
click to toggle source
# File lib/sktl_to_liquid/type.rb, line 49 def else_segment? segment.dig(:call_or_variable, :name).to_sym == :else end
enrolled_in_segment?()
click to toggle source
# File lib/sktl_to_liquid/type.rb, line 61 def enrolled_in_segment? [ :enrolled_in_learning_path?, :enrolled_in_course?, :progress_text ].include?(segment.dig(:call, :name).to_sym) end
filter_segment?()
click to toggle source
# File lib/sktl_to_liquid/type.rb, line 92 def filter_segment? FILTERS.include?(segment.dig(:call, :name)&.to_sym) || FILTERS.include?(segment.dig(:call_or_variable, :name)&.to_sym) end
learning_path_item_segment?()
click to toggle source
# File lib/sktl_to_liquid/type.rb, line 79 def learning_path_item_segment? segment.dig(:call, :name).to_sym == :learning_path_item end
loop_each_segment?()
click to toggle source
# File lib/sktl_to_liquid/type.rb, line 45 def loop_each_segment? segment[:chain].select { |s| s.key?(:call) }.any? { |s| s.dig(:call, :name).to_sym == :each } end
partial_segment?()
click to toggle source
# File lib/sktl_to_liquid/type.rb, line 53 def partial_segment? segment.dig(:call, :name).to_sym == :partial end
pluralize_segment?()
click to toggle source
# File lib/sktl_to_liquid/type.rb, line 75 def pluralize_segment? segment.dig(:call, :name).to_sym == :pluralize end