class SymbolW

Constants

FIX_ARGS

Public Class Methods

bestow_string_mutate_method(meth_def_name, meth_call_name) click to toggle source
# File lib/primitive_wrapper.rb, line 340
def self.bestow_string_mutate_method(meth_def_name, meth_call_name)
  define_method meth_def_name do |*args, &block| 
    prms = args.blockify_elements &FIX_ARGS
    str = @value.to_s
    str.send(meth_call_name, *prms, &block)
    @value = str.to_sym
  end  
end
bestow_string_mutate_methods(meths) click to toggle source
# File lib/primitive_wrapper.rb, line 391
def self.bestow_string_mutate_methods(meths)
  meths.each do |meth|
    bestow_string_mutate_method(meth, meth)
  end    
end
bestow_string_non_mutate_method(meth_def_name, meth_call_name, return_type = SymbolW) click to toggle source
# File lib/primitive_wrapper.rb, line 349
def self.bestow_string_non_mutate_method(meth_def_name, meth_call_name, return_type = SymbolW)
  if return_type==Symbol
    define_method meth_def_name do |*args, &block|
      prms = args.blockify_elements &FIX_ARGS
      @value.to_s.send(meth_call_name, *prms, &block).to_sym
    end
  elsif return_type==String
    define_method meth_def_name do |*args, &block|
      prms = args.blockify_elements &FIX_ARGS
      @value.to_s.send(meth_call_name, *prms, &block).to_s
    end
  elsif return_type==SymbolW
    define_method meth_def_name do |*args, &block|
      prms = args.blockify_elements &FIX_ARGS
      SymbolW.new @value.to_s.send(meth_call_name, *prms, &block).to_s.to_sym
    end
  else  # default type
    define_method meth_def_name do |*args, &block|
      prms = args.blockify_elements &FIX_ARGS
      @value.to_s.send(meth_call_name, *prms, &block)
    end
  end    
end
bestow_string_non_mutate_methods(meths, return_type = SymbolW) click to toggle source
# File lib/primitive_wrapper.rb, line 397
def self.bestow_string_non_mutate_methods(meths, return_type = SymbolW)
  meths.each do |meth|
    bestow_string_non_mutate_method(meth, meth, return_type)
  end    
end
bestow_symbol_method(meth_def_name, meth_call_name, mutate_self=false) click to toggle source
# File lib/primitive_wrapper.rb, line 373
def self.bestow_symbol_method(meth_def_name, meth_call_name, mutate_self=false)
  if mutate_self      
    define_method meth_def_name do |*args, &block| 
      margs = args.blockify_elements { |t| t.prim_value }       
      tval = @value.send(meth_call_name, *margs, &block)
      ensure_valid(tval, "symbol mutate method not valid")
      @value = tval
      return self
    end  
  else
    define_method meth_def_name do |*args, &block| 
      margs = args.blockify_elements { |t| t.prim_value }
      rtn = @value.send(meth_call_name, *margs, &block)
      return rtn
    end  
  end
end
bestow_symbol_methods(meths, mutate_self=false) click to toggle source
# File lib/primitive_wrapper.rb, line 403
def self.bestow_symbol_methods(meths, mutate_self=false)
  meths.each do |meth|
    dmeth=meth 
    if mutate_self
      dmeth = (meth.to_s + '!').to_sym
    end
    bestow_symbol_method(dmeth, meth, mutate_self)
  end    
end

Public Instance Methods

include?(pat) click to toggle source

why did I redefine this? don't remember … investigate later

# File lib/primitive_wrapper.rb, line 430
def include? pat
  self.to_s.include? pat.to_s
end
to_str() click to toggle source
# File lib/primitive_wrapper.rb, line 438
def to_str
  @value.to_s
end
to_sym() click to toggle source

old-fashioned defines:

# File lib/primitive_wrapper.rb, line 435
def to_sym
  @value
end
valid_type(prm) click to toggle source
# File lib/primitive_wrapper.rb, line 324
def valid_type(prm)
  return true if prm.kind_of? Symbol
  return true if prm.kind_of? SymbolW
  false
end