class Ellipses::Server::Symbols::Symbol
Attributes
depends[R]
Private Class Methods
from_meta(meta)
click to toggle source
# File lib/ellipses/server/symbols.rb, line 68 def from_meta(meta) new meta end
from_string(string)
click to toggle source
# File lib/ellipses/server/symbols.rb, line 64 def from_string(string) new Meta::Symbol.from_hash symbol: string end
new(meta)
click to toggle source
# File lib/ellipses/server/symbols.rb, line 16 def initialize(meta) @meta = meta @depends = [] end
Public Instance Methods
build(symbols)
click to toggle source
# File lib/ellipses/server/symbols.rb, line 21 def build(symbols) return if @meta.depends.nil? # To avoid a circular reference, skip dependency if it is this symbol @meta.depends.uniq.reject { |depend| depend == to_s }.each { |depend| depends << symbols.register(depend) } end
leaf?()
click to toggle source
# File lib/ellipses/server/symbols.rb, line 32 def leaf? depends.empty? end
path()
click to toggle source
# File lib/ellipses/server/symbols.rb, line 36 def path @path ||= @meta.path end
payload(rootdir, extension = nil)
click to toggle source
# File lib/ellipses/server/symbols.rb, line 40 def payload(rootdir, extension = nil) unless (file = where(rootdir, extension)) && !::File.directory?(file) raise BogusLeafError, "No source found for leaf symbol: #{self}" if leaf? return [] end ::File.readlines(file).tap do |lines| raise EmptyPayloadError, "Empty source for symbol: #{self}" if lines.empty? end end
to_s()
click to toggle source
# File lib/ellipses/server/symbols.rb, line 28 def to_s @meta.to_s end
Private Instance Methods
where(rootdir, extension = nil)
click to toggle source
# File lib/ellipses/server/symbols.rb, line 54 def where(rootdir, extension = nil) return ::File.exist?(path) ? ::File.join(rootdir, path) : nil if path paths = [base = ::File.join(rootdir, to_s)] paths.prepend("#{base}#{extension}") if extension paths.find { |path| ::File.exist?(path) } end