Class: Algebrick::Atom

Inherits:
Type show all
Includes:
Value
Defined in:
lib/algebrick/atom.rb

Overview

Representation of Atomic types

Instance Method Summary collapse

Methods included from Value

#inspect

Methods included from Matching

#any, #match, #match?, #on

Methods included from TypeCheck

#Child!, #Child?, #Match!, #Match?, #Type!, #Type?

Methods inherited from Type

#inspect, #match, #name

Methods included from Reclude

#include, #included

Methods included from MatcherDelegations

#!, #&, #>, #>>, #case, #|, #~

Constructor Details

#initialize(name, &block) ⇒ Atom

Returns a new instance of Atom.



20
21
22
23
# File 'lib/algebrick/atom.rb', line 20

def initialize(name, &block)
  super name, &block
  extend self
end

Instance Method Details

#==(other) ⇒ Object



33
34
35
# File 'lib/algebrick/atom.rb', line 33

def ==(other)
  self.equal? other
end

#be_kind_of(type) ⇒ Object



29
30
31
# File 'lib/algebrick/atom.rb', line 29

def be_kind_of(type)
  extend type
end

#pretty_print(q) ⇒ Object



45
46
47
# File 'lib/algebrick/atom.rb', line 45

def pretty_print(q)
  q.text to_s
end

#to_mObject



25
26
27
# File 'lib/algebrick/atom.rb', line 25

def to_m
  Matchers::Atom.new self
end

#to_sObject



41
42
43
# File 'lib/algebrick/atom.rb', line 41

def to_s
  name || 'nameless-atom'
end

#typeObject



37
38
39
# File 'lib/algebrick/atom.rb', line 37

def type
  self
end