Class: AutoC::Module

Inherits:
Object
  • Object
show all
Includes:
EntityContainer
Defined in:
lib/autoc/module.rb

Direct Known Subclasses

Docs

Defined Under Namespace

Modules: EntityContainer, SmartRenderer Classes: Builder, Header, Source, State, StreamFile

Constant Summary collapse

CAP =
"/* Automagically generated by AutoC #{AutoC::VERSION} */"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EntityContainer

#<<, #entities

Constructor Details

#initialize(name, stateful: true) ⇒ Module

Returns a new instance of Module.



55
56
57
58
# File 'lib/autoc/module.rb', line 55

def initialize(name, stateful: true)
  @name = name
  @stateful = stateful
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



47
48
49
# File 'lib/autoc/module.rb', line 47

def name
  @name
end

#source_countObject

Returns the value of attribute source_count.



49
50
51
# File 'lib/autoc/module.rb', line 49

def source_count
  @source_count
end

#source_thresholdObject

Returns the value of attribute source_threshold.



51
52
53
# File 'lib/autoc/module.rb', line 51

def source_threshold
  @source_threshold
end

Class Method Details

.render(name) {|m| ... } ⇒ Object

Yields:

  • (m)


93
94
95
96
97
# File 'lib/autoc/module.rb', line 93

def self.render(name, **, &code)
  m = self.new(name, **)
  yield(m) if block_given?
  m.render
end

Instance Method Details

#digestsObject



64
# File 'lib/autoc/module.rb', line 64

def digests = @digests ||= State.new(self).read

#headerObject



60
# File 'lib/autoc/module.rb', line 60

def header = @header ||= Header.new(self)

#renderObject



66
67
68
69
70
71
72
# File 'lib/autoc/module.rb', line 66

def render
  distribute_entities
  header.render
  sources.each(&:render)
  State.new(self).collect.write if stateful?
  self
end

#sourcesObject



62
# File 'lib/autoc/module.rb', line 62

def sources = @sources ||= (1..source_count).collect { |i| Source.new(self, i) }

#stateful?Boolean

Returns:

  • (Boolean)


53
# File 'lib/autoc/module.rb', line 53

def stateful? = @stateful == true

#total_entitiesObject



74
75
76
77
78
79
80
# File 'lib/autoc/module.rb', line 74

def total_entities
  @total_entities ||= begin
    set = ::Set.new
    entities.each { |e| set.merge(e.total_references) }
    set
  end
end