Class: MIME::Content::Text::Plain::Parser
- Inherits:
-
Object
- Object
- MIME::Content::Text::Plain::Parser
- Defined in:
- lib/safrano/multipart.rb
Overview
Parser for Text::Plain
Constant Summary collapse
- HMD_RGX =
/^([\w-]+)\s*:\s*(.*)/.freeze
Instance Method Summary collapse
- #addline(line) ⇒ Object
-
#initialize(target) ⇒ Parser
constructor
A new instance of Parser.
- #parse(level: 0) ⇒ Object
- #parse_head(line) ⇒ Object
Constructor Details
#initialize(target) ⇒ Parser
Returns a new instance of Parser.
201 202 203 204 205 |
# File 'lib/safrano/multipart.rb', line 201 def initialize(target) @state = :h @lines = [] @target = target end |
Instance Method Details
#addline(line) ⇒ Object
207 208 209 |
# File 'lib/safrano/multipart.rb', line 207 def addline(line) @lines << line end |
#parse(level: 0) ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/safrano/multipart.rb', line 222 def parse(level: 0) return unless @lines @level = level @lines.each do |line| case @state when :h parse_head(line) when :b @target.content << line end end @lines = nil @target.level = level @target end |