Class: Bukovina::Parsers::Memo
- Inherits:
-
Object
- Object
- Bukovina::Parsers::Memo
- Defined in:
- lib/bukovina/parsers/memo.rb
Constant Summary collapse
- Parsers =
Bukovina::Parsers
- RE =
/\A([#{Parsers::UPCHAR}#{Parsers::CHAR}#{Parsers::ACCENT}0-9\s‑;:'"«»\,()\.\-\?\/]+)\z/
- SUBPARSERS =
вход: значение поля “имя” включая словарь разных языков выход: обработанный словарь данных
{ 'год' => :year, 'дата' => :date, 'календарь' => :calendary, 'месяцеслов' => :calendary, 'собор' => :ignore, 'описание' => :type, 'служба' => :service, 'по' => :after, 'пред' => :before, 'навеч' => :inevening, }
- EVENTS =
Bukovina::Parsers::Event::EVENTS
- DAY =
%w(пн вт ср чт пт сб нд дн)
- PREF =
%w(до по близ)
- DATES =
%w(пасхе пасхи пасха)
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
2 3 4 |
# File 'lib/bukovina/parsers/memo.rb', line 2 def errors @errors end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
2 3 4 |
# File 'lib/bukovina/parsers/memo.rb', line 2 def target @target end |
Instance Method Details
#parse(memos, options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bukovina/parsers/memo.rb', line 29 def parse memos, = {} # TODO skip return if errors found # @target = [:target] res = case memos when Hash parsed = parse_hash( memos ) memos = post_hash_proc( parsed ) { memos: memos } when Array if memos.blank? @errors << Parsers::BukovinaInvalidValueError.new( "Value of memo " + "array is empty" ) ;end list = memos.map do |memo| parsed = parse_hash( memo ) post_hash_proc( parsed ) end.flatten.compact { memos: list } when NilClass @errors << Parsers::BukovinaInvalidValueError.new( "Event list" + "can't be blank" ) else raise Parsers::BukovinaInvalidClass, "Invalid class #{name.class} " + "for Memo line '#{name}'" ; end @errors.empty? && res || nil rescue Parsers::BukovinaError => e @errors << e nil ; end |