File: value/core/atom/string.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: Umu#6
  module: Value#8
  module: Core#10
has properties
function: make_string / 1 #101
  module: Atom#12
  class: String#14
inherits from
  Abstract ( Umu::Value::Core::Atom )
has properties
method: initialize / 1 #15
method: to_s #22
method: meth_show / 3 #27
method: meth_to_string / 3 #32
method: meth_append / 4 #77
method: meth_panic / 3 #89

Class Hierarchy

Code

   1  # coding: utf-8
   2  # frozen_string_literal: true
   3 
   4 
   5 
   6  module Umu
   7 
   8  module Value
   9 
  10  module Core
  11 
  12  module Atom
  13 
  14  class String < Abstract
  15      def initialize(val)
  16          ASSERT.kind_of val, ::String
  17 
  18          super
  19      end
  20 
  21 
  22      def to_s
  23          format "\"%s\"", Escape.unescape(self.val)
  24      end
  25 
  26 
  27      def meth_show(_loc, _env, _event)
  28          VC.make_string self.to_s
  29      end
  30 
  31 
  32      def meth_to_string(_loc, _env, _event)
  33          self
  34      end
  35 
  36 
  37      define_instance_method(
  38          :meth_is_less_than,
  39          :'<', [],
  40          [self], VCA::Bool
  41      )
  42 
  43 
  44      define_instance_method(
  45          :meth_is_greater_than,
  46          :'>', [],
  47          [self], VCA::Bool
  48      )
  49 
  50 
  51      define_instance_method(
  52          :meth_is_less_equal,
  53          :'<=', [],
  54          [self], VCA::Bool
  55      )
  56 
  57 
  58      define_instance_method(
  59          :meth_is_greater_equal,
  60          :'>=', [],
  61          [self], VCA::Bool
  62      )
  63 
  64 
  65      define_instance_method(
  66          :meth_compare,
  67          :'<=>', [],
  68          [self], VCAN::Int
  69      )
  70 
  71 
  72      define_instance_method(
  73          :meth_append,
  74          :'^', [],
  75          [self], self
  76      )
  77      def meth_append(_loc, _env, _event, other)
  78          ASSERT.kind_of other, String
  79 
  80          VC.make_string self.val + other.val
  81      end
  82 
  83 
  84      define_instance_method(
  85          :meth_panic,
  86          :panic!, [],
  87          [], VC::Unit
  88      )
  89      def meth_panic(loc, env, _event)
  90          raise X::Panic.new(loc, env, self.to_s)
  91      end
  92  end
  93  String.freeze
  94 
  95 
  96  end # Umu::Value::Core::Atom
  97 
  98 
  99  module_function
 100 
 101      def make_string(val)
 102          ASSERT.kind_of val, ::String
 103 
 104          Atom::String.new(val.freeze).freeze
 105      end
 106 
 107  end # Umu::Value::Core
 108 
 109  end # Umu::Value
 110 
 111  end # Umu