class SublimeSunippetter::Dsl

Dsl. this is dsl for Sunippetdefine.

Attributes

_output_path[RW]
_scope[RW]
requires[RW]
target_methods[RW]

Public Class Methods

new() click to toggle source

init default values

# File lib/sublime_sunippetter_dsl.rb, line 10
def initialize
  @target_methods = []
  @_scope = 'source.ruby'
  @_output_path = './'
  @requires = []
end

Public Instance Methods

add(method_name, *args) click to toggle source

add sunippet information

# File lib/sublime_sunippetter_dsl.rb, line 18
def add(method_name, *args)
  return if has_error?(method_name, *args)
  has_do_block = args.include?('block@d')
  has_brace_block = args.include?('block@b')
  args = delete_block_args args
  @target_methods << TargetMethod.new do |t|
    t.method_name = method_name
    t.args = args
    t.has_do_block = has_do_block
    t.has_brace_block = has_brace_block
  end
end
add_requires(*filenames) click to toggle source
# File lib/sublime_sunippetter_dsl.rb, line 31
def add_requires(*filenames)
  @requires = filenames
end
output_path(_output_path) click to toggle source

set sunippet output path

# File lib/sublime_sunippetter_dsl.rb, line 43
def output_path(_output_path)
  return if _output_path.nil?
  return if _output_path.empty?
  @_output_path = _output_path
end
scope(_scope) click to toggle source

set sunippet scope

# File lib/sublime_sunippetter_dsl.rb, line 36
def scope(_scope)
  return if _scope.nil?
  return if _scope.empty?
  @_scope = _scope
end

Private Instance Methods

delete_block_args(args) click to toggle source
# File lib/sublime_sunippetter_dsl.rb, line 59
def delete_block_args(args)
  args - ['block@b', 'block@d']
end
has_error?(method_name, *args) click to toggle source
# File lib/sublime_sunippetter_dsl.rb, line 51
def has_error?(method_name, *args)
  return true if method_name.nil?
  return true if method_name.empty?
  return true if args.each.include?(nil)
  return true if args.each.include?('')
  false
end