Class: Aranha::Parsers::Base
- Inherits:
-
Object
- Object
- Aranha::Parsers::Base
- Defined in:
- lib/aranha/parsers/base.rb
Direct Known Subclasses
Constant Summary collapse
- LOG_DIR_ENVVAR =
'ARANHA_PARSERS_LOG_DIR'
Instance Attribute Summary collapse
-
#source_address ⇒ Object
readonly
Returns the value of attribute source_address.
Class Method Summary collapse
Instance Method Summary collapse
- #content ⇒ String
-
#initialize(url) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(url) ⇒ Base
Returns a new instance of Base.
32 33 34 35 |
# File 'lib/aranha/parsers/base.rb', line 32 def initialize(url) @source_address = ::Aranha::Parsers::SourceAddress.new(url) log_content(source_address.serialize, '-source-address') end |
Instance Attribute Details
#source_address ⇒ Object (readonly)
Returns the value of attribute source_address.
30 31 32 |
# File 'lib/aranha/parsers/base.rb', line 30 def source_address @source_address end |
Class Method Details
.from_content(content) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/aranha/parsers/base.rb', line 12 def from_content(content) ::EacRubyUtils::Fs::Temp.on_file do |path| ::File.open(path.to_s, 'w:UTF-8') do |f| f.write content.dup.force_encoding('UTF-8') end r = new(path.to_path) r.content r end end |
.parse_content(content) ⇒ Object
23 24 25 |
# File 'lib/aranha/parsers/base.rb', line 23 def parse_content(content) from_content(content).data end |
Instance Method Details
#content ⇒ String
44 45 46 |
# File 'lib/aranha/parsers/base.rb', line 44 def content @content ||= log_content(source_address_content) end |