Class: GamesAndRpgParadise::Lpc::Geas::ForumCompacter

Inherits:
Base
  • Object
show all
Defined in:
lib/games_and_rpg_paradise/lpc/geas/forum_compacter.rb

Overview

GamesAndRpgParadise::Lpc::Geas::ForumCompacter

Constant Summary

Constants included from Base::Extensions::Colours

Base::Extensions::Colours::ARRAY_AVAILABLE_KONSOLE_COLOURS

Constants included from CommonExtensions

CommonExtensions::CONTROL_C_CODE, CommonExtensions::N

Instance Method Summary collapse

Methods included from Base::Extensions::Colours

ecomment, #efancy, #eparse, #forestgreen, #gold, #grey, #lightblue, #mediumseagreen, #mediumslateblue, #peru, #rev, sdir, sfancy, #sfile, simp, #teal, #yellow

Methods included from Base::Extensions::CommandlineArguments

#commandline_arguments?, #filter_away_commandline_arguments, #first_argument?, #first_non_hyphened_argument?, #set_commandline_arguments

Methods included from CommonExtensions

#cat, #cd, #cliner, #copy_file, #delete, #dirname_but_retains_the_trailing_slash, #disable_colours, #ensure_that_the_log_directory_exists, #esystem, #get_user_input, #infer_the_namespace, #is_on_roebe?, #log_dir?, #mkdir, #mkdir_then_cd_into_it, #mv, #namespace?, #opne, #opnn, #project_base_directory?, #project_image_directory?, #project_yaml_directory?, #rds, #register_sigint, #remove_this_directory, #rename_file, #reset_the_internal_hash, #return_pwd, #return_today, #touch_file, #wrap, #write_what_into

Constructor Details

#initialize(i, run_already = true) ⇒ ForumCompacter

#

initialize

#


28
29
30
31
32
33
34
# File 'lib/games_and_rpg_paradise/lpc/geas/forum_compacter.rb', line 28

def initialize(
    i, run_already = true
  )
  reset
  set_input(i)
  run if run_already
end

Instance Method Details

#parse_inputObject

#

parse_input

#


77
78
79
80
81
# File 'lib/games_and_rpg_paradise/lpc/geas/forum_compacter.rb', line 77

def parse_input
  day = @input.first.split(' ').first.delete(',')
  array_all_names = @input.map {|entry| entry.split(' ').last.delete('.') }.uniq
  report_result(day, array_all_names)
end

#report_result(day, array_all_names) ⇒ Object

#

report_result

#


86
87
88
# File 'lib/games_and_rpg_paradise/lpc/geas/forum_compacter.rb', line 86

def report_result(day, array_all_names)
  e day+' '+array_all_names.join(', ')+'.'
end

#resetObject

#

reset

#


39
40
41
# File 'lib/games_and_rpg_paradise/lpc/geas/forum_compacter.rb', line 39

def reset
  super()
end

#runObject

#

run

#


93
94
95
96
# File 'lib/games_and_rpg_paradise/lpc/geas/forum_compacter.rb', line 93

def run
  sanitize_input
  parse_input
end

#sanitize_inputObject

#

sanitize_input

#


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/games_and_rpg_paradise/lpc/geas/forum_compacter.rb', line 57

def sanitize_input
  if @input and @input.is_a?(Array)
    # ===================================================================== #
    # Get rid of all '`' characters first.
    # ===================================================================== #
    @input.map! {|entry|
      entry.delete!('`')
      entry.chop! if entry.end_with? '.'
      entry
    }
    # ===================================================================== #
    # Also get rid of empty entries.
    # ===================================================================== #
    @input.reject! {|entry| entry.empty? }
  end
end

#set_input(i) ⇒ Object

#

set_input

#


46
47
48
49
50
51
52
# File 'lib/games_and_rpg_paradise/lpc/geas/forum_compacter.rb', line 46

def set_input(i)
  i = i.first if i.is_a? Array
  if i.include? "\n"
    i = i.split("\n")
  end if i.is_a? String
  @input = i
end