Class: Luoma::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/luoma/expression.rb,
sig/luoma/expression.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, name, args, kwargs) ⇒ Filter

(t_token, Name, Array[Expression | KeywordArgument])

Parameters:



1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
# File 'lib/luoma/expression.rb', line 1082

def initialize(token, name, args, kwargs)
  @token = token
  @name = name
  @args = args
  @kwargs = kwargs

  @span = if args.empty? && kwargs.empty?
            token
          elsif kwargs.empty?
            Luoma.span(token, args.last.span)
          elsif args.empty?
            Luoma.span(token, kwargs.last.span)
          else
            Luoma.span(
              token,
              kwargs.last.token[1] > args.last.token[1] ? kwargs.last.span : args.last.span
            )
          end
end

Instance Attribute Details

#argsArray[Expression] (readonly)

Returns the value of attribute args.

Returns:



1079
1080
1081
# File 'lib/luoma/expression.rb', line 1079

def args
  @args
end

#kwargsArray[KeywordArgument] (readonly)

Returns the value of attribute kwargs.

Returns:



1079
1080
1081
# File 'lib/luoma/expression.rb', line 1079

def kwargs
  @kwargs
end

#nameVariable (readonly)

Returns the value of attribute name.

Returns:



1079
1080
1081
# File 'lib/luoma/expression.rb', line 1079

def name
  @name
end

#spant_token (readonly)

Returns the value of attribute span.

Returns:

  • (t_token)


1079
1080
1081
# File 'lib/luoma/expression.rb', line 1079

def span
  @span
end

#tokent_token (readonly)

Returns the value of attribute token.

Returns:

  • (t_token)


1079
1080
1081
# File 'lib/luoma/expression.rb', line 1079

def token
  @token
end

Instance Method Details

#childrenArray[Luoma::_Traversable]

Returns:



1102
1103
1104
# File 'lib/luoma/expression.rb', line 1102

def children
  @kwargs.empty? ? @args : [*@args, *@kwargs.map(&:expression)]
end

#to_s::String

Returns:

  • (::String)


1106
1107
1108
1109
1110
1111
1112
# File 'lib/luoma/expression.rb', line 1106

def to_s
  return @name.to_s if @args.empty? && @kwargs.empty?

  args = @args.join(", ")
  args << ", " << @kwargs.join(",") unless @kwargs.empty?
  "#{@name}: #{args}"
end