class ChemistryParadise::ShowElement
Constants
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
- PERIODIC_TABLE
#¶ ↑
PERIODIC_TABLE
¶ ↑#¶ ↑
Public Class Methods
Public Instance Methods
new_position?()
click to toggle source
opnn()
click to toggle source
process_input()
click to toggle source
report_result()
click to toggle source
#¶ ↑
report_result
¶ ↑
#¶ ↑
# File lib/chemistry_paradise/show_element.rb, line 103 def report_result current_position = PERIODIC_TABLE[@name_of_the_element] current_position = current_position + new_position? opnn; e PERIODIC_TABLE.invert[current_position]+' is at position '+ sfancy(current_position.to_s)+'.' end
reset()
click to toggle source
run()
click to toggle source
set_batch(on_which_token = '+')
click to toggle source
#¶ ↑
set_batch
¶ ↑
This will set both (1) the name and (2) the relative position.
#¶ ↑
# File lib/chemistry_paradise/show_element.rb, line 86 def set_batch(on_which_token = '+') _ = @input.split(on_which_token) set_name_of_the_element _[0] _[1] = '-'+_[1].to_s if on_which_token == '-' set_relative_position _[1] end
set_input(i = '')
click to toggle source
set_name_of_the_element(i = nil)
click to toggle source
#¶ ↑
set_name_of_the_element
¶ ↑
#¶ ↑
# File lib/chemistry_paradise/show_element.rb, line 113 def set_name_of_the_element(i = nil) # ======================================================================= # # if the input is a number, we invert the PERIODIC_TABLE. # ======================================================================= # if i =~ /^\d+$/ i = PERIODIC_TABLE.invert[i.to_i] end @name_of_the_element = i end