Class: Chemtrail::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/chemtrail/function.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, *arguments) ⇒ Function

Returns a new instance of Function.



4
5
6
7
# File 'lib/chemtrail/function.rb', line 4

def initialize(name, *arguments)
  @name = name
  @arguments = arguments
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



2
3
4
# File 'lib/chemtrail/function.rb', line 2

def arguments
  @arguments
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/chemtrail/function.rb', line 2

def name
  @name
end

Instance Method Details

#argument_listObject



9
10
11
12
13
# File 'lib/chemtrail/function.rb', line 9

def argument_list
  @argument_list ||= arguments.map do |argument|
    Chemtrail::ReferencePresenter.new(argument).to_parameter
  end
end

#to_hashObject



15
16
17
18
19
# File 'lib/chemtrail/function.rb', line 15

def to_hash
  {
    name => argument_list.count > 1 ? argument_list : argument_list.first || ""
  }
end