Class: Anchor::Types::NodeStream

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/anchor/types.rb

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ NodeStream

Returns a new instance of NodeStream.



6
# File 'lib/anchor/types.rb', line 6

def initialize(root) = @root = root

Instance Method Details

#each(&blk) ⇒ Object



8
9
10
11
# File 'lib/anchor/types.rb', line 8

def each(&blk)
  return enum_for(:each) unless blk
  walk(@root, &blk)
end

#enumsObject



17
# File 'lib/anchor/types.rb', line 17

def enums = of_kind(Anchor::Types::Enum)

#of_kind(klass) ⇒ Object



13
14
15
# File 'lib/anchor/types.rb', line 13

def of_kind(klass)
  select { |n| n.is_a?(Class) ? n <= klass : n.is_a?(klass) }
end

#referencesObject



18
# File 'lib/anchor/types.rb', line 18

def references = of_kind(Anchor::Types::Reference)

#resourcesObject



19
# File 'lib/anchor/types.rb', line 19

def resources = of_kind(Anchor::Types::Resource)