Class: Yutani::Reference
- Inherits:
-
Object
- Object
- Yutani::Reference
- Defined in:
- lib/yutani/reference.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #attr ⇒ Object
- #find_matching_resources_in_module!(mod) ⇒ Object
-
#initialize(path = '.', t, n, a) ⇒ Reference
constructor
A new instance of Reference.
- #relative_path(source_mod) ⇒ Object
- #resource_name ⇒ Object
- #resource_type ⇒ Object
Constructor Details
#initialize(path = '.', t, n, a) ⇒ Reference
Returns a new instance of Reference.
8 9 10 11 12 13 |
# File 'lib/yutani/reference.rb', line 8 def initialize(path='.', t, n, a) @path = path @t = t @n = n @a = a end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/yutani/reference.rb', line 6 def path @path end |
Instance Method Details
#attr ⇒ Object
29 30 31 |
# File 'lib/yutani/reference.rb', line 29 def attr @a end |
#find_matching_resources_in_module!(mod) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/yutani/reference.rb', line 33 def find_matching_resources_in_module!(mod) resolutions = [] # we currently support strings for t n and a, and regex # for n only mod.resources.each do |resource| if resource.resource_type == self.resource_type.to_sym case self.resource_name when Regexp if resource.resource_name =~ self.resource_name resolutions.push(resource) end when Symbol if resource.resource_name == self.resource_name.to_sym resolutions.push(resource) end else raise "unsupported class #{self.resource_name.class}" end end end resolutions end |
#relative_path(source_mod) ⇒ Object
15 16 17 18 19 |
# File 'lib/yutani/reference.rb', line 15 def relative_path(source_mod) source_path = Pathname.new(source_mod.path) target_path = Pathname.new(@path) target_path.relative_path_from(source_path).to_s end |
#resource_name ⇒ Object
25 26 27 |
# File 'lib/yutani/reference.rb', line 25 def resource_name @n end |
#resource_type ⇒ Object
21 22 23 |
# File 'lib/yutani/reference.rb', line 21 def resource_type @t end |