class Cog::Seed::Feature

Template for a method in a target language

Attributes

access[R]

@return [Symbol] access modifier. One of `:public`, `:protected`, or `:private`

name[R]

@return [String] name of the method

params[R]

@return [Array<Var>] list of parameters

return_type[R]

@return [Symbol] the return type of the feature

seed[R]

@api developer @return [Seed] seed to which this feature belongs

Public Class Methods

new(seed, name, opt={}) click to toggle source

@api developer @param seed [Seed] seed to which this feature belongs @param name [String] name of the feature @option opt [Symbol] :access (:private) one of `:public`, `:protected`, or `private` @option opt [Boolean] :abstract (false) is this an abstract feature? If so, no implementation will be generated. Note that all abstract features are virtual @option opt [Boolean] :virtual (false) is this a virtual feature? Virtual features can be replaced in subclasses

# File lib/cog/seed/feature.rb, line 31
def initialize(seed, name, opt={})
  @seed = seed
  @name = name.to_s.to_ident
  @access = (opt[:access] || :private).to_sym
  @abstract = !!opt[:abstract]
  @virtual = !!opt[:virtual]
  @params = [] # [Var]
  @return_type = :void
end

Public Instance Methods

<=>(other) click to toggle source

Sort by name

# File lib/cog/seed/feature.rb, line 71
def <=>(other)
  @name <=> other.name
end
abstract?() click to toggle source

@return [Boolean] is this an abstract method?

# File lib/cog/seed/feature.rb, line 42
def abstract?
  @abstract
end
desc() click to toggle source
# File lib/cog/seed/feature.rb, line 56
def desc
  @desc || 'Undocumented'
end
keep_name() click to toggle source
# File lib/cog/seed/feature.rb, line 60
def keep_name
  "#{@seed.name}_#{@name}"
end
returns_a_value?() click to toggle source

@return [Boolean] does this feature return a value?

# File lib/cog/seed/feature.rb, line 52
def returns_a_value?
  @return_type != :void
end
stamp_method() click to toggle source
# File lib/cog/seed/feature.rb, line 64
def stamp_method
  l = Cog.active_language
  ext = @seed.in_header? ? l.seed_header : l.seed_extension
  stamp "cog/#{l.key}/feature.#{ext}"
end
virtual?() click to toggle source

@return [Boolean] is this a virtual method?

# File lib/cog/seed/feature.rb, line 47
def virtual?
  @abstract || @virtual
end