Class: Skeem::SkmArity

Inherits:
Struct
  • Object
show all
Defined in:
lib/skeem/s_expr_nodes.rb

Overview

class

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#highObject

Returns the value of attribute high

Returns:

  • (Object)

    the current value of high



298
299
300
# File 'lib/skeem/s_expr_nodes.rb', line 298

def high
  @high
end

#lowObject

Returns the value of attribute low

Returns:

  • (Object)

    the current value of low



298
299
300
# File 'lib/skeem/s_expr_nodes.rb', line 298

def low
  @low
end

Instance Method Details

#==(other) ⇒ Object



310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/skeem/s_expr_nodes.rb', line 310

def ==(other)
  return true if object_id == other.object_id

  result = false

  case other
    when SkmArity
      result = true if (low == other.low) && (high == other.high)
    when Array
      result = true if (low == other.first) && (high == other.last)
    when Integer
      result = true if (low == other) && (high == other)
  end

  result
end

#nullary?Boolean

rubocop: disable Style/NumericPredicate

Returns:

  • (Boolean)


301
302
303
# File 'lib/skeem/s_expr_nodes.rb', line 301

def nullary?
  low.zero? && high == 0
end

#variadic?Boolean

rubocop: enable Style/NumericPredicate

Returns:

  • (Boolean)


306
307
308
# File 'lib/skeem/s_expr_nodes.rb', line 306

def variadic?
  high == '*'
end