class Cog::Seed::Feature
Template for a method in a target language
Attributes
@return [Symbol] access modifier. One of `:public`, `:protected`, or `:private`
@return [String] name of the method
@return [Array<Var>] list of parameters
@return [Symbol] the return type of the feature
@api developer @return [Seed] seed to which this feature belongs
Public Class Methods
@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
Sort by name
# File lib/cog/seed/feature.rb, line 71 def <=>(other) @name <=> other.name end
@return [Boolean] is this an abstract method?
# File lib/cog/seed/feature.rb, line 42 def abstract? @abstract end
# File lib/cog/seed/feature.rb, line 56 def desc @desc || 'Undocumented' end
# File lib/cog/seed/feature.rb, line 60 def keep_name "#{@seed.name}_#{@name}" end
@return [Boolean] does this feature return a value?
# File lib/cog/seed/feature.rb, line 52 def returns_a_value? @return_type != :void end
# 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
@return [Boolean] is this a virtual method?
# File lib/cog/seed/feature.rb, line 47 def virtual? @abstract || @virtual end