Class: Html2rss::AutoSource::Segment
- Inherits:
-
Data
- Object
- Data
- Html2rss::AutoSource::Segment
- Defined in:
- lib/html2rss/auto_source/segment.rb
Overview
One candidate content block discovered by Segmenter.
Constant Summary collapse
- STRATEGIES =
Allowed Segmenter strategies.
%i[semantic list cluster].to_set.freeze
Instance Attribute Summary collapse
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#primary_link ⇒ Object
readonly
Returns the value of attribute primary_link.
-
#root_node ⇒ Object
readonly
Returns the value of attribute root_node.
-
#strategy ⇒ Object
readonly
Returns the value of attribute strategy.
Class Method Summary collapse
Instance Attribute Details
#position ⇒ Object (readonly)
Returns the value of attribute position
7 8 9 |
# File 'lib/html2rss/auto_source/segment.rb', line 7 def position @position end |
#primary_link ⇒ Object (readonly)
Returns the value of attribute primary_link
7 8 9 |
# File 'lib/html2rss/auto_source/segment.rb', line 7 def primary_link @primary_link end |
#root_node ⇒ Object (readonly)
Returns the value of attribute root_node
7 8 9 |
# File 'lib/html2rss/auto_source/segment.rb', line 7 def root_node @root_node end |
#strategy ⇒ Object (readonly)
Returns the value of attribute strategy
7 8 9 |
# File 'lib/html2rss/auto_source/segment.rb', line 7 def strategy @strategy end |
Class Method Details
.build(root_node:, strategy:, position:, primary_link: nil) ⇒ Segment
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/html2rss/auto_source/segment.rb', line 15 def self.build(root_node:, strategy:, position:, primary_link: nil) raise ArgumentError, 'root_node must be SST::Node' unless root_node.is_a?(SST::Node) unless primary_link.nil? || primary_link.is_a?(SST::Node) raise ArgumentError, 'primary_link must be SST::Node or nil' end raise ArgumentError, "unknown strategy: #{strategy.inspect}" unless Segment::STRATEGIES.include?(strategy) raise ArgumentError, 'position must be Integer' unless position.is_a?(Integer) new(root_node:, primary_link:, strategy:, position:) end |