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_value, #on

Methods included from TypeCheck

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

Methods inherited from Type

#inspect, #match, #name

Methods included from Reclude

#include, #included, #included_into

Methods included from MatcherDelegations

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

Constructor Details

- (Atom) initialize(name, &block)

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

- (Object) ==(other)



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

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

- (Object) be_kind_of(type)



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

def be_kind_of(type)
  extend type
end

- (Object) pretty_print(q)



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

def pretty_print(q)
  q.text to_s
end

- (Object) to_m



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

def to_m
  Matchers::Atom.new self
end

- (Object) to_s



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

def to_s
  name
end

- (Object) type



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

def type
  self
end