Class: TMBundle::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/tm_bundle.rb

Direct Known Subclasses

Command, Macro, Snippet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Action

Returns a new instance of Action.



15
16
17
18
# File 'lib/tm_bundle.rb', line 15

def initialize(path)
  @path = path
  @data = Plutil.load_json(path)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &blk) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/tm_bundle.rb', line 32

def method_missing(meth, *args, &blk)
  meth_name = meth.to_s
  if @data.key?(meth_name) 
    @data[meth_name]
  else 
    super
  end
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



14
15
16
# File 'lib/tm_bundle.rb', line 14

def data
  @data
end

#pathObject

Returns the value of attribute path.



14
15
16
# File 'lib/tm_bundle.rb', line 14

def path
  @path
end

Instance Method Details

#expected_pathObject



24
25
26
# File 'lib/tm_bundle.rb', line 24

def expected_path
  @expected_path ||= data['name'].gsub(/[.:\/]+/, '.' => '_', ':' => '', '/' => '') + path.extname
end

#inspectObject



20
21
22
# File 'lib/tm_bundle.rb', line 20

def inspect
  "#{self.class.name}:> #{data['name']} > `#{path.basename}`"
end

#unmatching_path?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/tm_bundle.rb', line 28

def unmatching_path?
  expected_path != path.basename.to_s
end