我打印斑马TLP-2844打印机上的一些标签,并已通过发送EPL指令来共享USB打印机如下精做它在Windows上:
键入Label.prn>\my-pc\zebra
它似乎也适用于串口
键入Label.prn> COM1
现在我正试图在Linux上做同样的事情,但它变得非常难!我的第一个猜测是:
cat Label.prn | 的/ dev /总线/ USB/005/002
因为我的打印机在005总线,设备002(用lsusb命令检查)但它根本不起作用,因为我得到以下内容:
bash:/ dev/bus/usb/005/002:权限被拒绝
任何猜测?
这是交易:我需要用一些方法扩展class Box的特定实例.我需要包含实时内部模块的方法,我希望Box实例能够动态地包含模块.现在我使用带有eval的钩子:
class Box
def after_initialize
if self.injected_module.present?
eval("class << self; include #{self.injected_module}; end")
end
end
end
Run Code Online (Sandbox Code Playgroud)
它工作得很好但是当我使用eval时我真的感觉很脏.我正在寻找类似的东西:
module_to_inject = self.injected_module
self.eigenclass.class_eval do
include module_to_inject
end
Run Code Online (Sandbox Code Playgroud)
但是我无法让eigenclass在没有monkeypatching类的情况下运行class_eval:
class Box; def eigenclass; class << self; self; end end end
Run Code Online (Sandbox Code Playgroud)
有一种美丽(可靠)的方式让我这样做吗?
看这个:
"nAo".match(/(nao)/i) # => #<MatchData "nAo" 1:"nAo">
"nÃo".match(/(não)/i) # => nil
Run Code Online (Sandbox Code Playgroud)
有没有办法解决这个问题?
编辑:似乎ruby在i标志的regexp比较中缺乏对unicode字符的支持(忽略大小写)...使用MRI 1.8.7p249