Class: SleepingKingStudios::Tools::Messages::Strategies::FileStrategy

Inherits:
HashStrategy show all
Defined in:
lib/sleeping_king_studios/tools/messages/strategies/file_strategy.rb

Overview

Messaging strategy that loads message templates from the given file.

Defined Under Namespace

Classes: FileError

Instance Attribute Summary collapse

Attributes inherited from HashStrategy

#templates

Instance Method Summary collapse

Methods inherited from SleepingKingStudios::Tools::Messages::Strategy

#call

Constructor Details

#initialize(file_name) ⇒ FileStrategy

Returns a new instance of FileStrategy.

Parameters:

  • file_name (String)

    the full path to the file with the templates data.



14
15
16
17
18
19
20
21
22
# File 'lib/sleeping_king_studios/tools/messages/strategies/file_strategy.rb', line 14

def initialize(file_name)
  validate_file_name(file_name)

  @file_name = file_name
  raw_data   = read_file(file_name)
  templates  = parse_templates(raw_data)

  super(templates)
end

Instance Attribute Details

#file_nameString (readonly)

Returns the full path to the file with the templates data.

Returns:

  • (String)

    the full path to the file with the templates data.



25
26
27
# File 'lib/sleeping_king_studios/tools/messages/strategies/file_strategy.rb', line 25

def file_name
  @file_name
end