Class: Baykit::BayServer::Util::Message
- Inherits:
-
Object
- Object
- Baykit::BayServer::Util::Message
- Includes:
- Bcf
- Defined in:
- lib/baykit/bayserver/util/message.rb
Instance Attribute Summary collapse
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
Instance Method Summary collapse
-
#get(key, *args) ⇒ Object
key : symbol.
- #init(file_prefix, locale) ⇒ Object
-
#initialize ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize ⇒ Message
Returns a new instance of Message.
14 15 16 |
# File 'lib/baykit/bayserver/util/message.rb', line 14 def initialize @messages = {} end |
Instance Attribute Details
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
12 13 14 |
# File 'lib/baykit/bayserver/util/message.rb', line 12 def @messages end |
Instance Method Details
#get(key, *args) ⇒ Object
key : symbol
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/baykit/bayserver/util/message.rb', line 43 def get(key, *args) if !key.instance_of? Symbol raise RuntimeError "Key must be symbol" end msg = [key] if msg == nil msg = key.to_s end sprintf(msg, *args) end |
#init(file_prefix, locale) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/baykit/bayserver/util/message.rb', line 18 def init(file_prefix, locale) lang = locale.language file = file_prefix + ".bcf" if(StringUtil.set?(lang) && lang != "en") file = file_prefix + "_" + lang + ".bcf" end if(!File.exist?(file)) BayLog.warn("Cannot find message send_file: %s", file) return end p = BcfParser.new() doc = p.parse(file) doc.content_list.each do |o| if(o.instance_of? BcfKeyVal) [o.key.to_sym] = o.value end end end |