Class: SktlToLiquid::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/sktl_to_liquid/type.rb

Constant Summary collapse

FILTERS =
[:replace, :truncate_words, :downcase].freeze
OPERATORS =
[:greater, :or, :and, :equals, :subtract, :differs, :add].freeze

Instance Method Summary collapse

Constructor Details

#initialize(segment) ⇒ Type

Returns a new instance of Type.



7
8
9
# File 'lib/sktl_to_liquid/type.rb', line 7

def initialize(segment)
  @segment = segment
end

Instance Method Details

#to_symObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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