Class: PageStructuredData::PageTypes::InteractionStatistic
- Inherits:
-
Object
- Object
- PageStructuredData::PageTypes::InteractionStatistic
- Includes:
- SchemaNode
- Defined in:
- app/src/page_structured_data/page_types/interaction_statistic.rb
Overview
schema.org InteractionCounter structured data.
Constant Summary collapse
- ACTION_TYPES =
{ like: 'LikeAction', likes: 'LikeAction', comment: 'CommentAction', comments: 'CommentAction', share: 'ShareAction', shares: 'ShareAction', }.freeze
Instance Attribute Summary collapse
-
#interaction_service ⇒ Object
readonly
Returns the value of attribute interaction_service.
-
#interaction_type ⇒ Object
readonly
Returns the value of attribute interaction_type.
-
#user_interaction_count ⇒ Object
readonly
Returns the value of attribute user_interaction_count.
Class Method Summary collapse
- .comment(user_interaction_count) ⇒ Object
- .like(user_interaction_count) ⇒ Object
- .share(user_interaction_count) ⇒ Object
Instance Method Summary collapse
-
#initialize(interaction_type:, user_interaction_count:, interaction_service: nil) ⇒ InteractionStatistic
constructor
A new instance of InteractionStatistic.
- #to_h ⇒ Object
Constructor Details
#initialize(interaction_type:, user_interaction_count:, interaction_service: nil) ⇒ InteractionStatistic
Returns a new instance of InteractionStatistic.
32 33 34 35 36 |
# File 'app/src/page_structured_data/page_types/interaction_statistic.rb', line 32 def initialize(interaction_type:, user_interaction_count:, interaction_service: nil) @interaction_type = interaction_type @user_interaction_count = user_interaction_count @interaction_service = interaction_service end |
Instance Attribute Details
#interaction_service ⇒ Object (readonly)
Returns the value of attribute interaction_service.
18 19 20 |
# File 'app/src/page_structured_data/page_types/interaction_statistic.rb', line 18 def interaction_service @interaction_service end |
#interaction_type ⇒ Object (readonly)
Returns the value of attribute interaction_type.
18 19 20 |
# File 'app/src/page_structured_data/page_types/interaction_statistic.rb', line 18 def interaction_type @interaction_type end |
#user_interaction_count ⇒ Object (readonly)
Returns the value of attribute user_interaction_count.
18 19 20 |
# File 'app/src/page_structured_data/page_types/interaction_statistic.rb', line 18 def user_interaction_count @user_interaction_count end |
Class Method Details
.comment(user_interaction_count) ⇒ Object
24 25 26 |
# File 'app/src/page_structured_data/page_types/interaction_statistic.rb', line 24 def self.comment(user_interaction_count) new(interaction_type: :comment, user_interaction_count: user_interaction_count) end |
.like(user_interaction_count) ⇒ Object
20 21 22 |
# File 'app/src/page_structured_data/page_types/interaction_statistic.rb', line 20 def self.like(user_interaction_count) new(interaction_type: :like, user_interaction_count: user_interaction_count) end |
.share(user_interaction_count) ⇒ Object
28 29 30 |
# File 'app/src/page_structured_data/page_types/interaction_statistic.rb', line 28 def self.share(user_interaction_count) new(interaction_type: :share, user_interaction_count: user_interaction_count) end |
Instance Method Details
#to_h ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'app/src/page_structured_data/page_types/interaction_statistic.rb', line 38 def to_h compact_node( '@type': 'InteractionCounter', interactionType: interaction_type_to_h, userInteractionCount: user_interaction_count, interactionService: object_to_h(interaction_service) ) end |