Class: Veritas::Function::String::Length

Inherits:
Veritas::Function show all
Includes:
Unary
Defined in:
lib/veritas/function/string/length.rb

Overview

A class representing a length function

Defined Under Namespace

Modules: Methods

Instance Attribute Summary

Attributes included from Operation::Unary

#operand

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Unary

#==, #call, #rename

Methods included from Comparator

#compare

Methods included from Unary::Callable

#call, #included

Methods included from Operation::Unary

#initialize

Methods included from Immutable

#dup, #freeze, included, #memoize, #memoized

Methods inherited from Veritas::Function

extract_value, #rename, rename_attributes

Methods included from AbstractClass

included

Methods included from Visitable

#accept

Class Method Details

.call(value) ⇒ Integer

Return the string length

Examples:

length = Length.call(value)

Parameters:

Returns:

API:

  • public



21
22
23
# File 'lib/veritas/function/string/length.rb', line 21

def self.call(value)
  value.length
end

Instance Method Details

#inspectString

Return a string representing the length function

Examples:

length.inspect  # => 'LENGTH("a string")'

Returns:

API:

  • public



42
43
44
# File 'lib/veritas/function/string/length.rb', line 42

def inspect
  "LENGTH(#{operand.inspect})"
end

#typeClass<Attribute::Integer>

Return the type returned from #call

Returns:

API:

  • public



30
31
32
# File 'lib/veritas/function/string/length.rb', line 30

def type
  Attribute::Integer
end