Class: Axiom::Function::String::Length

Inherits:
Axiom::Function show all
Includes:
Unary
Defined in:
lib/axiom/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

Methods included from Unary

#call, #rename, #type

Methods included from Unary::Callable

#call, #included

Methods included from Operation::Unary

#initialize

Methods inherited from Axiom::Function

extract_value, rename_attributes, #type

Methods included from Visitable

#accept

Class Method Details

.call(value) ⇒ Integer

Return the string length

Examples:

length = Length.call(value)

Parameters:

Returns:

  • (Integer)


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

def self.call(value)
  value.length
end

.typeClass<Types::Integer>

Return the type returned from #call

Examples:

type = Axiom::Function::String.type  # => Axiom::Types::Integer

Returns:

  • (Class<Types::Integer>)


33
34
35
# File 'lib/axiom/function/string/length.rb', line 33

def self.type
  Types::Integer
end