Sha256: 26c2e7c779b4ca12715350ce6dac17badc1d34f9653d8e3956663ce16ded3be6

Contents?: true

Size: 540 Bytes

Versions: 4

Compression:

Stored size: 540 Bytes

Contents

require 'forwardable'

class Rupture::Symbol # Use for symbols
  extend Forwardable
  def_delegators :@symbol, :to_s, :name, :namespace

  def initialize(*args)
    Utils.verify_args(args, 1, 2)
    @symbol = args.join("/").to_sym
  end

  alias inspect to_s
end

class Symbol # Use for keywords
  def name
    parse_namespace unless @name
    @name
  end

  def namespace
    parse_namespace unless @name
    @namespace
  end

private

  def parse_namespace
    @name, *ns = to_s.split('/').reverse
    @namespace = ns.join('/')
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rupture-0.3.0 lib/rupture/symbol.rb
rupture-0.2.1 lib/rupture/symbol.rb
rupture-0.2.0 lib/rupture/symbol.rb
rupture-0.1.0 lib/rupture/symbol.rb