Class: Riml::ImportedClass
- Inherits:
-
Object
- Object
- Riml::ImportedClass
- Defined in:
- lib/riml/imported_class.rb
Constant Summary collapse
- ANCHOR_BEGIN =
'\A'
- ANCHOR_END =
'\Z'
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#constructor ⇒ Object
stubbed out constructor function.
- #constructor_name ⇒ Object
- #constructor_obj_name ⇒ Object
- #global_import? ⇒ Boolean
-
#globbed? ⇒ Boolean
an ImportedClass is #globbed? if its name contains 1 or more ‘*’ characters.
- #imported? ⇒ Boolean
-
#initialize(name) ⇒ ImportedClass
constructor
A new instance of ImportedClass.
-
#match?(class_name) ⇒ Boolean
returns MatchData or ‘nil`.
-
#match_regexp ⇒ Object
returns Regexp.
- #scope_modifier ⇒ Object
Constructor Details
#initialize(name) ⇒ ImportedClass
Returns a new instance of ImportedClass.
10 11 12 |
# File 'lib/riml/imported_class.rb', line 10 def initialize(name) @name = rm_modifier(name) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/riml/imported_class.rb', line 9 def name @name end |
Instance Method Details
#constructor ⇒ Object
stubbed out constructor function
46 47 48 49 50 |
# File 'lib/riml/imported_class.rb', line 46 def constructor @contructor ||= begin DefNode.new('!', nil, scope_modifier, constructor_name, ['...'], [], Nodes.new([])) end end |
#constructor_name ⇒ Object
52 53 54 |
# File 'lib/riml/imported_class.rb', line 52 def constructor_name "#{@name}Constructor" end |
#constructor_obj_name ⇒ Object
56 57 58 |
# File 'lib/riml/imported_class.rb', line 56 def constructor_obj_name @name[0, 1].downcase + @name[1..-1] + "Obj" end |
#global_import? ⇒ Boolean
37 38 39 |
# File 'lib/riml/imported_class.rb', line 37 def global_import? @name == '*' end |
#globbed? ⇒ Boolean
an ImportedClass is #globbed? if its name contains 1 or more ‘*’ characters.
20 21 22 |
# File 'lib/riml/imported_class.rb', line 20 def globbed? not @name.index('*').nil? end |
#imported? ⇒ Boolean
14 15 16 |
# File 'lib/riml/imported_class.rb', line 14 def imported? true end |
#match?(class_name) ⇒ Boolean
returns MatchData or ‘nil`
25 26 27 |
# File 'lib/riml/imported_class.rb', line 25 def match?(class_name) match_regexp.match(rm_modifier(class_name)) end |
#match_regexp ⇒ Object
returns Regexp
30 31 32 33 34 35 |
# File 'lib/riml/imported_class.rb', line 30 def match_regexp @match_regexp ||= begin normalized_glob = @name.gsub(/\*/, '.*?') Regexp.new(ANCHOR_BEGIN + normalized_glob + ANCHOR_END) end end |
#scope_modifier ⇒ Object
41 42 43 |
# File 'lib/riml/imported_class.rb', line 41 def scope_modifier 'g:' end |