Class: Luoma::Filter
- Inherits:
-
Object
- Object
- Luoma::Filter
- Defined in:
- lib/luoma/expression.rb,
sig/luoma/expression.rbs
Instance Attribute Summary collapse
-
#args ⇒ Array[Expression]
readonly
Returns the value of attribute args.
-
#kwargs ⇒ Array[KeywordArgument]
readonly
Returns the value of attribute kwargs.
-
#name ⇒ Variable
readonly
Returns the value of attribute name.
-
#span ⇒ t_token
readonly
Returns the value of attribute span.
-
#token ⇒ t_token
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #children ⇒ Array[Luoma::_Traversable]
-
#initialize(token, name, args, kwargs) ⇒ Filter
constructor
(t_token, Name, Array[Expression | KeywordArgument]).
- #to_s ⇒ ::String
Constructor Details
#initialize(token, name, args, kwargs) ⇒ Filter
(t_token, Name, Array[Expression | KeywordArgument])
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
#args ⇒ Array[Expression] (readonly)
Returns the value of attribute args.
1079 1080 1081 |
# File 'lib/luoma/expression.rb', line 1079 def args @args end |
#kwargs ⇒ Array[KeywordArgument] (readonly)
Returns the value of attribute kwargs.
1079 1080 1081 |
# File 'lib/luoma/expression.rb', line 1079 def kwargs @kwargs end |
#name ⇒ Variable (readonly)
Returns the value of attribute name.
1079 1080 1081 |
# File 'lib/luoma/expression.rb', line 1079 def name @name end |
#span ⇒ t_token (readonly)
Returns the value of attribute span.
1079 1080 1081 |
# File 'lib/luoma/expression.rb', line 1079 def span @span end |
#token ⇒ t_token (readonly)
Returns the value of attribute token.
1079 1080 1081 |
# File 'lib/luoma/expression.rb', line 1079 def token @token end |
Instance Method Details
#children ⇒ Array[Luoma::_Traversable]
1102 1103 1104 |
# File 'lib/luoma/expression.rb', line 1102 def children @kwargs.empty? ? @args : [*@args, *@kwargs.map(&:expression)] end |
#to_s ⇒ ::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 |