Class: Cog::Seed::Var
Overview
Template for a variable in a target language
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#name ⇒ String
readonly
Name of the variable.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Sort by name.
-
#initialize(type, name, opt = {}) ⇒ Var
constructor
A new instance of Var.
- #qualify? ⇒ Boolean
- #stamp_decl(qualify = false) ⇒ Object
Methods included from Generator
Methods included from Generator::LanguageMethods
#end_all_scopes, #include_guard_begin, #named_scope_begin, #scope_begin, #scope_end, #use_named_scope, #warning
Methods included from Generator::Filters
Methods included from Generator::FileMethods
#copy_file_if_missing, #files_are_same?, #get_template, #touch_directory, #touch_file
Constructor Details
#initialize(type, name, opt = {}) ⇒ Var
Returns a new instance of Var.
19 20 21 22 23 24 |
# File 'lib/cog/seed/var.rb', line 19 def initialize(type, name, opt={}) @type = type @name = name.to_s.to_ident @desc = opt[:desc] @scope = opt[:scope] end |
Instance Attribute Details
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
12 13 14 |
# File 'lib/cog/seed/var.rb', line 12 def desc @desc end |
#name ⇒ String (readonly)
Returns name of the variable.
10 11 12 |
# File 'lib/cog/seed/var.rb', line 10 def name @name end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
16 17 18 |
# File 'lib/cog/seed/var.rb', line 16 def scope @scope end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
14 15 16 |
# File 'lib/cog/seed/var.rb', line 14 def type @type end |
Instance Method Details
#<=>(other) ⇒ Object
Sort by name
37 38 39 |
# File 'lib/cog/seed/var.rb', line 37 def <=>(other) @name <=> other end |
#qualify? ⇒ Boolean
26 27 28 |
# File 'lib/cog/seed/var.rb', line 26 def qualify? @qualify end |
#stamp_decl(qualify = false) ⇒ Object
30 31 32 33 34 |
# File 'lib/cog/seed/var.rb', line 30 def stamp_decl(qualify = false) l = Cog.active_language @qualify = qualify && @scope stamp "cog/#{l.key}/var_decl.#{l.seed_extension}" end |