Class: Fable::Divert

Inherits:
RuntimeObject show all
Defined in:
lib/fable/divert.rb

Instance Attribute Summary collapse

Attributes inherited from RuntimeObject

#original_object, #own_debug_metadata, #parent, #path

Instance Method Summary collapse

Methods inherited from RuntimeObject

#compact_path_string, #convert_path_to_relative, #copy, #debug_line_number_of_path, #debug_metadata, #indentation_string, #initialize, #resolve_path, #root_content_container

Constructor Details

This class inherits a constructor from Fable::RuntimeObject

Instance Attribute Details

#external_argumentsObject

Returns the value of attribute external_arguments.



3
4
5
# File 'lib/fable/divert.rb', line 3

def external_arguments
  @external_arguments
end

#is_conditionalObject Also known as: is_conditional?

Returns the value of attribute is_conditional.



3
4
5
# File 'lib/fable/divert.rb', line 3

def is_conditional
  @is_conditional
end

#is_externalObject Also known as: is_external?

Returns the value of attribute is_external.



3
4
5
# File 'lib/fable/divert.rb', line 3

def is_external
  @is_external
end

#pushes_to_stackObject Also known as: pushes_to_stack?

Returns the value of attribute pushes_to_stack.



3
4
5
# File 'lib/fable/divert.rb', line 3

def pushes_to_stack
  @pushes_to_stack
end

#stack_push_typeObject

Returns the value of attribute stack_push_type.



3
4
5
# File 'lib/fable/divert.rb', line 3

def stack_push_type
  @stack_push_type
end

#target_pathObject

Returns the value of attribute target_path.



3
4
5
# File 'lib/fable/divert.rb', line 3

def target_path
  @target_path
end

#target_pointerObject

Returns the value of attribute target_pointer.



3
4
5
# File 'lib/fable/divert.rb', line 3

def target_pointer
  @target_pointer
end

#variable_divert_nameObject

Returns the value of attribute variable_divert_name.



3
4
5
# File 'lib/fable/divert.rb', line 3

def variable_divert_name
  @variable_divert_name
end

Instance Method Details

#==(other_divert) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fable/divert.rb', line 56

def ==(other_divert)
  if other_divert.is_a?(Divert) && !other_divert.nil?
    if self.has_variable_target? == other_divert.has_variable_target?
      if self.has_variable_target?
        return self.variable_divert_name == other_divert.variable_divert_name
      else
        return self.target_path == other_divert.target_path
      end
    end
  end
  return false
end

#has_variable_target?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/fable/divert.rb', line 69

def has_variable_target?
  !variable_divert_name.nil?
end

#target_path_stringObject



42
43
44
45
46
# File 'lib/fable/divert.rb', line 42

def target_path_string
  return nil if target_path.nil?

  return compact_path_string(target_path)
end

#target_path_string=(value) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/fable/divert.rb', line 48

def target_path_string=(value)
  if value.nil?
    self.target_path = nil
  else
    self.target_path = Path.new(value)
  end
end

#to_sObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/fable/divert.rb', line 73

def to_s
  if has_variable_target?
    return "Divert(variable: #{variable_divert_name})"
  elsif target_path.nil?
    return "Divert(null)"
  else
    result = ""

    target_string = target_path.to_s
    target_line_number = debug_line_number_of_path(target_path)
    if !target_line_number.nil?
      target_string = "line #{target_line_number}"
    end

    push_type = ""
    if pushes_to_stack?
      if stack_push_type == :FUNCTION
        push_type = " function"
      else
        push_type = " tunnel"
      end
    end

    "Divert#{'?' if is_conditional?}#{push_type} -> #{target_path_string} (#{target_string})"
  end
end