class Aio::Text::Block

Attributes

content[RW]
line[RW]

Public Class Methods

new(block) click to toggle source
# File lib/aio/core/text/block.rb, line 5
def initialize(block)
  @block = block
end

Public Instance Methods

[](sym) click to toggle source
# File lib/aio/core/text/block.rb, line 17
def [](sym)
  @block[sym]
end
inspect() click to toggle source
# File lib/aio/core/text/block.rb, line 9
def inspect
  @block.inspect
end
match_string(str) click to toggle source

加入content和行数信息

# File lib/aio/core/text/block.rb, line 74
def match_string(str)
  MatchStringInfo.new(str, content, line)
end
method_missing(m, *args) click to toggle source
Calls superclass method
# File lib/aio/core/text/block.rb, line 78
def method_missing(m, *args)
  if @block.respond_to? m
    @block.send(m, args)

  else
    super
  end
end
nil?() click to toggle source
# File lib/aio/core/text/block.rb, line 13
def nil?
  @block.nil?
end
update(info, sym, str=nil) click to toggle source

有两种更新的方式,不加str 那么就是从block中的提取 如果有str, 则直接使用str

# File lib/aio/core/text/block.rb, line 23
def update(info, sym, str=nil)
  sym = sym.to_sym
  if info.nil?
    print_error "请检查update中的第一个参数是否定义" 
    pp caller
  end

  if str.nil?
    info[sym] = match_string(self[sym].strip)
  else
    info[sym] = match_string(str.to_s.strip)
  end
end
update_arr(info, sym) click to toggle source
# File lib/aio/core/text/block.rb, line 37
def update_arr(info, sym)
  sym = sym.to_sym
  info[sym] ||= []
  info[sym] << match_string(self[sym].strip)
end
update_hash(info, sym, key, val) click to toggle source
# File lib/aio/core/text/block.rb, line 43
def update_hash(info, sym, key, val)
  sym = sym.to_sym
  info[sym] ||= {}
  info[sym][key] = match_string(val.strip)
end
warning(info, sym, level, mod, opt={}) click to toggle source

参数info 放置useful 参数sym 为Symbol类型的标示 参数level 为 :serious 或 :ordinary 参数mod 一般为self 参数opt 当block中没有sym项时使用

# File lib/aio/core/text/block.rb, line 54
def warning(info, sym, level, mod, opt={})
  sym = sym.to_sym
  self.update(info, sym, opt[:string])
  # Aio::Text::Warning 类中的warning方法
  mod.warning_klass.warning(info, sym, level, mod, opt[:force])
end
warning_ordinary(info, sym, mod, opt={}) click to toggle source
# File lib/aio/core/text/block.rb, line 67
def warning_ordinary(info, sym, mod, opt={})
  sym = sym.to_sym
  self.update(info, sym, opt[:string])
  mod.warning_klass.warning_ordinary(info, sym, mod, opt[:force])
end
warning_serious(info, sym, mod, opt={}) click to toggle source
# File lib/aio/core/text/block.rb, line 61
def warning_serious(info, sym, mod, opt={})
  sym = sym.to_sym
  self.update(info, sym, opt[:string])
  mod.warning_klass.warning_serious(info, sym, mod, opt[:force])
end