Module: NseData
- Defined in:
- lib/nse_data.rb,
lib/nse_data/version.rb,
lib/nse_data/api_manager.rb,
lib/nse_data/config/base.rb,
lib/nse_data/config/logger.rb,
lib/nse_data/cache/cache_store.rb,
lib/nse_data/cache/cache_policy.rb,
lib/nse_data/http_client/base_client.rb,
lib/nse_data/http_client/faraday_client.rb
Overview
The NseData module serves as the namespace for the NSE Data gem, which provides an interface to interact with and retrieve stock market data from the National Stock Exchange of India.
Defined Under Namespace
Modules: Cache, Config, HttpClient Classes: APIManager, Error
Constant Summary collapse
- VERSION =
'0.1.0'
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Object
Configure the logger for the NseData gem.
-
.define_api_methods ⇒ Object
This module provides functionality for accessing NSE data.
-
.list_all_endpoints ⇒ Array
Returns a list of all available endpoints.
-
.logger ⇒ Logger
Access the configured logger.
Class Method Details
.configure {|config| ... } ⇒ Object
Configure the logger for the NseData gem.
This method allows users to customize the logger used throughout the library. To use it, call ‘NseData.configure` and provide a block to set up the logger.
Example:
NseData.configure do |config|
custom_logger = Logger.new('nse_data.log')
custom_logger.level = Logger::DEBUG
config.logger = custom_logger
end
45 46 47 48 |
# File 'lib/nse_data.rb', line 45 def configure @logger_config ||= Config::Logger.new yield(@logger_config) if block_given? end |
.define_api_methods ⇒ Object
This module provides functionality for accessing NSE data.
15 16 17 18 19 20 21 22 |
# File 'lib/nse_data.rb', line 15 def define_api_methods api_manager = APIManager.new api_manager.endpoints.each_key do |method_name| define_singleton_method("fetch_#{method_name}") do api_manager.fetch_data(method_name).body end end end |
.list_all_endpoints ⇒ Array
Returns a list of all available endpoints.
27 28 29 |
# File 'lib/nse_data.rb', line 27 def list_all_endpoints @list_all_endpoints ||= APIManager.new.load_endpoints end |
.logger ⇒ Logger
Access the configured logger.
This method returns the Logger instance configured through ‘NseData.configure`.
56 57 58 |
# File 'lib/nse_data.rb', line 56 def logger @logger_config&.logger || (raise 'Logger not configured. Please call NseData.configure first.') end |