Module: HardwareInformation::PurchasedHardware

Included in:
GUI::Gtk::PurchasedHardwareModule, GUI::Gtk::ShowInputDevicesModule
Defined in:
lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb

Overview

HardwareInformation::PurchasedHardware

Constant Summary collapse

COLOUR_PURCHASED_AT_THIS_DATE =
#

COLOUR_PURCHASED_AT_THIS_DATE

#
'mistyrose'
MAIN_DIV =
#

MAIN_DIV

CSS-related Constants are defined next.

#
'pad0_4em mart0_1em'
LINUX_YAML =
#

LINUX_YAML

A hardcoded path.

#
'/home/x/data/PC/OS/LINUX/yaml/'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_bought_at(i) ⇒ Object

#

HardwareInformation::PurchasedHardware.add_bought_at

This method will only add non-nil values.

#


179
180
181
182
183
# File 'lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb', line 179

def self.add_bought_at(i)
  unless i.nil?
    @array_date_bought_at << i
  end
end

.add_to_the_total_cost(i, optional_year = nil) ⇒ Object

#

HardwareInformation::PurchasedHardware.add_to_the_total_cost

Since as of November 2023 we will also keep track of the year in which the purchase has been made. This is optional though.

#


86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb', line 86

def self.add_to_the_total_cost(
    i, optional_year = nil
  )
  i = i.to_f
  @total_cost += i
  if optional_year
    if @hash_yearly_purchases_made.has_key? optional_year
      @hash_yearly_purchases_made[optional_year] += i
    else
      @hash_yearly_purchases_made[optional_year] = i
    end
  end
end

.body_css_classObject

#

HardwareInformation::PurchasedHardware.body_css_class

#


39
40
41
# File 'lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb', line 39

def self.body_css_class
  'BG_BLACK pad0_4em'
end

.body_css_styleObject

#

HardwareInformation::PurchasedHardware.body_css_style

#


46
47
48
49
50
51
52
53
54
# File 'lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb', line 46

def self.body_css_style
  return '
border:        1px solid orange;
border-radius: 24px;
color:         #ceffce;
width:         84%;

'
end

.bought_at?Boolean

#

HardwareInformation::PurchasedHardware.bought_at?

#

Returns:

  • (Boolean)


188
189
190
# File 'lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb', line 188

def self.bought_at?
  return @array_date_bought_at
end

.file_my_hardwareObject

#

HardwareInformation::PurchasedHardware.file_my_hardware

All the important data is stored in the following .yml file:

bl /home/x/data/personal/yaml/my_hardware/my_hardware.yml
#


136
137
138
# File 'lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb', line 136

def self.file_my_hardware
  '/home/x/data/personal/yaml/my_hardware/my_hardware.yml'
end

.hash_yearly_purchases_made?Boolean

#

HardwareInformation::PurchasedHardware.hash_yearly_purchases_made?

#

Returns:

  • (Boolean)


76
77
78
# File 'lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb', line 76

def self.hash_yearly_purchases_made?
  @hash_yearly_purchases_made
end

.linux_yaml_directory?Boolean

#

HardwareInformation::PurchasedHardware.linux_yaml_directory?

#

Returns:

  • (Boolean)


124
125
126
# File 'lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb', line 124

def self.linux_yaml_directory?
  LINUX_YAML
end

.my_hardware(i = file_my_hardware) ⇒ Object

#

HardwareInformation::PurchasedHardware.my_hardware

This method will return the hash I use for the hardware I have purchased over the years.

#


146
147
148
# File 'lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb', line 146

def self.my_hardware(i = file_my_hardware)
  YAML.load_file(i)
end

.return_dataset_from_the_file_computer_hardwareObject

#

HardwareInformation::PurchasedHardware.return_dataset_from_the_file_computer_hardware

This will return the dataset stored in the .yml file.

#


162
163
164
165
166
167
# File 'lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb', line 162

def self.return_dataset_from_the_file_computer_hardware
  _ = file_computer_hardware?
  if File.exist? _
    return YAML.load_file(_)
  end
end

.title?Boolean

#

HardwareInformation::PurchasedHardware.title?

#

Returns:

  • (Boolean)


32
33
34
# File 'lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb', line 32

def self.title?
  'Meine Hardware'
end

.total_cost?Boolean

#

HardwareInformation::PurchasedHardware.total_cost?

#

Returns:

  • (Boolean)


103
104
105
# File 'lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb', line 103

def self.total_cost?
  @total_cost
end

Instance Method Details

#main_dataset?Boolean

#

main_dataset?

#

Returns:

  • (Boolean)


153
154
155
# File 'lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb', line 153

def main_dataset?
  ::HardwareInformation::PurchasedHardware.my_hardware
end