Class: AuctionFunCore::Entities::Auction
- Inherits:
-
ROM::Struct
- Object
- ROM::Struct
- AuctionFunCore::Entities::Auction
- Defined in:
- lib/auction_fun_core/entities/auction.rb
Overview
Defines the Auction class as Entity. It appears to be a simple data structure class representing auction-related information.
Instance Method Summary collapse
-
#initial_bid ⇒ Money
Retrieves the initial bid amount for an auction as a Money object.
-
#minimal_bid ⇒ Money
Retrieves the minimal bid amount for an auction as a Money object.
-
#not_started? ⇒ Boolean
Checks if an auction has not started yet.
-
#started? ⇒ Boolean
Checks if an auction has already started.
-
#winner? ⇒ Boolean
Checks if an auction has a winner.
Instance Method Details
#initial_bid ⇒ Money
Retrieves the initial bid amount for an auction as a Money object.
This method creates and returns a new Money object that represents the initial bid amount required to start bidding in the auction. It utilizes ‘initial_bid_cents` and `initial_bid_currency` attributes to construct the Money object, ensuring that the amount is correctly represented in the specified currency.
17 18 19 |
# File 'lib/auction_fun_core/entities/auction.rb', line 17 def initial_bid Money.new(initial_bid_cents, initial_bid_currency) end |
#minimal_bid ⇒ Money
Retrieves the minimal bid amount for an auction as a Money object.
This method creates and returns a new Money object that represents the minimal bid amount required to participate in the auction. It uses ‘minimal_bid_cents` and `minimal_bid_currency` attributes to construct the Money object.
28 29 30 |
# File 'lib/auction_fun_core/entities/auction.rb', line 28 def minimal_bid Money.new(minimal_bid_cents, minimal_bid_currency) end |
#not_started? ⇒ Boolean
Checks if an auction has not started yet.
This method verifies if an auction is still in the “scheduled” status and whether its start time (‘started_at`) is still in the future compared to the current time. The auction is considered not started if it is scheduled and the start time has not yet been reached.
62 63 64 |
# File 'lib/auction_fun_core/entities/auction.rb', line 62 def not_started? status == "scheduled" && Time.current <= started_at end |
#started? ⇒ Boolean
Checks if an auction has already started.
This method determines if an auction has begun based on its status and by comparing the auction’s start time (‘started_at`) with the current time. An auction is considered started if it is no longer scheduled (i.e., its status is not “scheduled”) and the start time (`started_at`) is equal to or before the current time.
50 51 52 |
# File 'lib/auction_fun_core/entities/auction.rb', line 50 def started? status != "scheduled" && Time.current > started_at end |
#winner? ⇒ Boolean
Checks if an auction has a winner.
This method determines if an auction has a winner based on the presence of a ‘winner_id`. It returns true if the `winner_id` is present, indicating that the auction has concluded with a winning bidder.
39 40 41 |
# File 'lib/auction_fun_core/entities/auction.rb', line 39 def winner? winner_id.present? end |