Module: Trith::Core::Textual::Constructors

Defined in:
lib/trith/core/textual.rb

Overview

Textual constructors.

Instance Method Summary (collapse)

Instance Method Details

- (String) chr(obj)

Parameters:

  • (Integer, String) obj

Returns:

  • (String)


39
40
41
42
43
44
45
# File 'lib/trith/core/textual.rb', line 39

def chr(obj)
  case obj
    when Integer then obj.chr(Encoding::UTF_8)
    when String  then obj.chr
    else raise Machine::InvalidOperandError.new(obj, :chr)
  end
end

- (String) text(obj)

Parameters:

  • (Object) obj

Returns:

  • (String)


50
51
52
53
54
55
# File 'lib/trith/core/textual.rb', line 50

def text(obj)
  case obj
    when String then obj
    else obj.to_s # FIXME
  end
end