Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby27/share/ruby/rss
File: rss.rb
# frozen_string_literal: false
[0] Fix | Delete
require "time"
[1] Fix | Delete
[2] Fix | Delete
class Time
[3] Fix | Delete
class << self
[4] Fix | Delete
unless respond_to?(:w3cdtf)
[5] Fix | Delete
# This method converts a W3CDTF string date/time format to Time object.
[6] Fix | Delete
#
[7] Fix | Delete
# The W3CDTF format is defined here: http://www.w3.org/TR/NOTE-datetime
[8] Fix | Delete
#
[9] Fix | Delete
# Time.w3cdtf('2003-02-15T13:50:05-05:00')
[10] Fix | Delete
# # => 2003-02-15 10:50:05 -0800
[11] Fix | Delete
# Time.w3cdtf('2003-02-15T13:50:05-05:00').class
[12] Fix | Delete
# # => Time
[13] Fix | Delete
def w3cdtf(date)
[14] Fix | Delete
if /\A\s*
[15] Fix | Delete
(-?\d+)-(\d\d)-(\d\d)
[16] Fix | Delete
(?:T
[17] Fix | Delete
(\d\d):(\d\d)(?::(\d\d))?
[18] Fix | Delete
(\.\d+)?
[19] Fix | Delete
(Z|[+-]\d\d:\d\d)?)?
[20] Fix | Delete
\s*\z/ix =~ date and (($5 and $8) or (!$5 and !$8))
[21] Fix | Delete
datetime = [$1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i]
[22] Fix | Delete
usec = 0
[23] Fix | Delete
usec = $7.to_f * 1000000 if $7
[24] Fix | Delete
zone = $8
[25] Fix | Delete
if zone
[26] Fix | Delete
off = zone_offset(zone, datetime[0])
[27] Fix | Delete
datetime = apply_offset(*(datetime + [off]))
[28] Fix | Delete
datetime << usec
[29] Fix | Delete
time = Time.utc(*datetime)
[30] Fix | Delete
force_zone!(time, zone, off)
[31] Fix | Delete
time
[32] Fix | Delete
else
[33] Fix | Delete
datetime << usec
[34] Fix | Delete
Time.local(*datetime)
[35] Fix | Delete
end
[36] Fix | Delete
else
[37] Fix | Delete
raise ArgumentError.new("invalid date: #{date.inspect}")
[38] Fix | Delete
end
[39] Fix | Delete
end
[40] Fix | Delete
end
[41] Fix | Delete
end
[42] Fix | Delete
[43] Fix | Delete
unless method_defined?(:w3cdtf)
[44] Fix | Delete
# This method converts a Time object to a String. The String contains the
[45] Fix | Delete
# time in W3CDTF date/time format.
[46] Fix | Delete
#
[47] Fix | Delete
# The W3CDTF format is defined here: http://www.w3.org/TR/NOTE-datetime
[48] Fix | Delete
#
[49] Fix | Delete
# Time.now.w3cdtf
[50] Fix | Delete
# # => "2013-08-26T14:12:10.817124-07:00"
[51] Fix | Delete
def w3cdtf
[52] Fix | Delete
if usec.zero?
[53] Fix | Delete
fraction_digits = 0
[54] Fix | Delete
else
[55] Fix | Delete
fraction_digits = strftime('%6N').index(/0*\z/)
[56] Fix | Delete
end
[57] Fix | Delete
xmlschema(fraction_digits)
[58] Fix | Delete
end
[59] Fix | Delete
end
[60] Fix | Delete
end
[61] Fix | Delete
[62] Fix | Delete
[63] Fix | Delete
require "English"
[64] Fix | Delete
require_relative "utils"
[65] Fix | Delete
require_relative "converter"
[66] Fix | Delete
require_relative "xml-stylesheet"
[67] Fix | Delete
[68] Fix | Delete
module RSS
[69] Fix | Delete
# The URI of the RSS 1.0 specification
[70] Fix | Delete
URI = "http://purl.org/rss/1.0/"
[71] Fix | Delete
[72] Fix | Delete
DEBUG = false # :nodoc:
[73] Fix | Delete
[74] Fix | Delete
# The basic error all other RSS errors stem from. Rescue this error if you
[75] Fix | Delete
# want to handle any given RSS error and you don't care about the details.
[76] Fix | Delete
class Error < StandardError; end
[77] Fix | Delete
[78] Fix | Delete
# RSS, being an XML-based format, has namespace support. If two namespaces are
[79] Fix | Delete
# declared with the same name, an OverlappedPrefixError will be raised.
[80] Fix | Delete
class OverlappedPrefixError < Error
[81] Fix | Delete
attr_reader :prefix
[82] Fix | Delete
def initialize(prefix)
[83] Fix | Delete
@prefix = prefix
[84] Fix | Delete
end
[85] Fix | Delete
end
[86] Fix | Delete
[87] Fix | Delete
# The InvalidRSSError error is the base class for a variety of errors
[88] Fix | Delete
# related to a poorly-formed RSS feed. Rescue this error if you only
[89] Fix | Delete
# care that a file could be invalid, but don't care how it is invalid.
[90] Fix | Delete
class InvalidRSSError < Error; end
[91] Fix | Delete
[92] Fix | Delete
# Since RSS is based on XML, it must have opening and closing tags that
[93] Fix | Delete
# match. If they don't, a MissingTagError will be raised.
[94] Fix | Delete
class MissingTagError < InvalidRSSError
[95] Fix | Delete
attr_reader :tag, :parent
[96] Fix | Delete
def initialize(tag, parent)
[97] Fix | Delete
@tag, @parent = tag, parent
[98] Fix | Delete
super("tag <#{tag}> is missing in tag <#{parent}>")
[99] Fix | Delete
end
[100] Fix | Delete
end
[101] Fix | Delete
[102] Fix | Delete
# Some tags must only exist a specific number of times in a given RSS feed.
[103] Fix | Delete
# If a feed has too many occurrences of one of these tags, a TooMuchTagError
[104] Fix | Delete
# will be raised.
[105] Fix | Delete
class TooMuchTagError < InvalidRSSError
[106] Fix | Delete
attr_reader :tag, :parent
[107] Fix | Delete
def initialize(tag, parent)
[108] Fix | Delete
@tag, @parent = tag, parent
[109] Fix | Delete
super("tag <#{tag}> is too much in tag <#{parent}>")
[110] Fix | Delete
end
[111] Fix | Delete
end
[112] Fix | Delete
[113] Fix | Delete
# Certain attributes are required on specific tags in an RSS feed. If a feed
[114] Fix | Delete
# is missing one of these attributes, a MissingAttributeError is raised.
[115] Fix | Delete
class MissingAttributeError < InvalidRSSError
[116] Fix | Delete
attr_reader :tag, :attribute
[117] Fix | Delete
def initialize(tag, attribute)
[118] Fix | Delete
@tag, @attribute = tag, attribute
[119] Fix | Delete
super("attribute <#{attribute}> is missing in tag <#{tag}>")
[120] Fix | Delete
end
[121] Fix | Delete
end
[122] Fix | Delete
[123] Fix | Delete
# RSS does not allow for free-form tag names, so if an RSS feed contains a
[124] Fix | Delete
# tag that we don't know about, an UnknownTagError is raised.
[125] Fix | Delete
class UnknownTagError < InvalidRSSError
[126] Fix | Delete
attr_reader :tag, :uri
[127] Fix | Delete
def initialize(tag, uri)
[128] Fix | Delete
@tag, @uri = tag, uri
[129] Fix | Delete
super("tag <#{tag}> is unknown in namespace specified by uri <#{uri}>")
[130] Fix | Delete
end
[131] Fix | Delete
end
[132] Fix | Delete
[133] Fix | Delete
# Raised when an unexpected tag is encountered.
[134] Fix | Delete
class NotExpectedTagError < InvalidRSSError
[135] Fix | Delete
attr_reader :tag, :uri, :parent
[136] Fix | Delete
def initialize(tag, uri, parent)
[137] Fix | Delete
@tag, @uri, @parent = tag, uri, parent
[138] Fix | Delete
super("tag <{#{uri}}#{tag}> is not expected in tag <#{parent}>")
[139] Fix | Delete
end
[140] Fix | Delete
end
[141] Fix | Delete
# For backward compatibility :X
[142] Fix | Delete
NotExceptedTagError = NotExpectedTagError # :nodoc:
[143] Fix | Delete
[144] Fix | Delete
# Attributes are in key-value form, and if there's no value provided for an
[145] Fix | Delete
# attribute, a NotAvailableValueError will be raised.
[146] Fix | Delete
class NotAvailableValueError < InvalidRSSError
[147] Fix | Delete
attr_reader :tag, :value, :attribute
[148] Fix | Delete
def initialize(tag, value, attribute=nil)
[149] Fix | Delete
@tag, @value, @attribute = tag, value, attribute
[150] Fix | Delete
message = "value <#{value}> of "
[151] Fix | Delete
message << "attribute <#{attribute}> of " if attribute
[152] Fix | Delete
message << "tag <#{tag}> is not available."
[153] Fix | Delete
super(message)
[154] Fix | Delete
end
[155] Fix | Delete
end
[156] Fix | Delete
[157] Fix | Delete
# Raised when an unknown conversion error occurs.
[158] Fix | Delete
class UnknownConversionMethodError < Error
[159] Fix | Delete
attr_reader :to, :from
[160] Fix | Delete
def initialize(to, from)
[161] Fix | Delete
@to = to
[162] Fix | Delete
@from = from
[163] Fix | Delete
super("can't convert to #{to} from #{from}.")
[164] Fix | Delete
end
[165] Fix | Delete
end
[166] Fix | Delete
# for backward compatibility
[167] Fix | Delete
UnknownConvertMethod = UnknownConversionMethodError # :nodoc:
[168] Fix | Delete
[169] Fix | Delete
# Raised when a conversion failure occurs.
[170] Fix | Delete
class ConversionError < Error
[171] Fix | Delete
attr_reader :string, :to, :from
[172] Fix | Delete
def initialize(string, to, from)
[173] Fix | Delete
@string = string
[174] Fix | Delete
@to = to
[175] Fix | Delete
@from = from
[176] Fix | Delete
super("can't convert #{@string} to #{to} from #{from}.")
[177] Fix | Delete
end
[178] Fix | Delete
end
[179] Fix | Delete
[180] Fix | Delete
# Raised when a required variable is not set.
[181] Fix | Delete
class NotSetError < Error
[182] Fix | Delete
attr_reader :name, :variables
[183] Fix | Delete
def initialize(name, variables)
[184] Fix | Delete
@name = name
[185] Fix | Delete
@variables = variables
[186] Fix | Delete
super("required variables of #{@name} are not set: #{@variables.join(', ')}")
[187] Fix | Delete
end
[188] Fix | Delete
end
[189] Fix | Delete
[190] Fix | Delete
# Raised when a RSS::Maker attempts to use an unknown maker.
[191] Fix | Delete
class UnsupportedMakerVersionError < Error
[192] Fix | Delete
attr_reader :version
[193] Fix | Delete
def initialize(version)
[194] Fix | Delete
@version = version
[195] Fix | Delete
super("Maker doesn't support version: #{@version}")
[196] Fix | Delete
end
[197] Fix | Delete
end
[198] Fix | Delete
[199] Fix | Delete
module BaseModel
[200] Fix | Delete
include Utils
[201] Fix | Delete
[202] Fix | Delete
def install_have_child_element(tag_name, uri, occurs, name=nil, type=nil)
[203] Fix | Delete
name ||= tag_name
[204] Fix | Delete
add_need_initialize_variable(name)
[205] Fix | Delete
install_model(tag_name, uri, occurs, name)
[206] Fix | Delete
[207] Fix | Delete
writer_type, reader_type = type
[208] Fix | Delete
def_corresponded_attr_writer name, writer_type
[209] Fix | Delete
def_corresponded_attr_reader name, reader_type
[210] Fix | Delete
install_element(name) do |n, elem_name|
[211] Fix | Delete
<<-EOC
[212] Fix | Delete
if @#{n}
[213] Fix | Delete
"\#{@#{n}.to_s(need_convert, indent)}"
[214] Fix | Delete
else
[215] Fix | Delete
''
[216] Fix | Delete
end
[217] Fix | Delete
EOC
[218] Fix | Delete
end
[219] Fix | Delete
end
[220] Fix | Delete
alias_method(:install_have_attribute_element, :install_have_child_element)
[221] Fix | Delete
[222] Fix | Delete
def install_have_children_element(tag_name, uri, occurs, name=nil, plural_name=nil)
[223] Fix | Delete
name ||= tag_name
[224] Fix | Delete
plural_name ||= "#{name}s"
[225] Fix | Delete
add_have_children_element(name, plural_name)
[226] Fix | Delete
add_plural_form(name, plural_name)
[227] Fix | Delete
install_model(tag_name, uri, occurs, plural_name, true)
[228] Fix | Delete
[229] Fix | Delete
def_children_accessor(name, plural_name)
[230] Fix | Delete
install_element(name, "s") do |n, elem_name|
[231] Fix | Delete
<<-EOC
[232] Fix | Delete
rv = []
[233] Fix | Delete
@#{n}.each do |x|
[234] Fix | Delete
value = "\#{x.to_s(need_convert, indent)}"
[235] Fix | Delete
rv << value if /\\A\\s*\\z/ !~ value
[236] Fix | Delete
end
[237] Fix | Delete
rv.join("\n")
[238] Fix | Delete
EOC
[239] Fix | Delete
end
[240] Fix | Delete
end
[241] Fix | Delete
[242] Fix | Delete
def install_text_element(tag_name, uri, occurs, name=nil, type=nil,
[243] Fix | Delete
disp_name=nil)
[244] Fix | Delete
name ||= tag_name
[245] Fix | Delete
disp_name ||= name
[246] Fix | Delete
self::ELEMENTS << name unless self::ELEMENTS.include?(name)
[247] Fix | Delete
add_need_initialize_variable(name)
[248] Fix | Delete
install_model(tag_name, uri, occurs, name)
[249] Fix | Delete
[250] Fix | Delete
def_corresponded_attr_writer(name, type, disp_name)
[251] Fix | Delete
def_corresponded_attr_reader(name, type || :convert)
[252] Fix | Delete
install_element(name) do |n, elem_name|
[253] Fix | Delete
<<-EOC
[254] Fix | Delete
if respond_to?(:#{n}_content)
[255] Fix | Delete
content = #{n}_content
[256] Fix | Delete
else
[257] Fix | Delete
content = @#{n}
[258] Fix | Delete
end
[259] Fix | Delete
if content
[260] Fix | Delete
rv = "\#{indent}<#{elem_name}>"
[261] Fix | Delete
value = html_escape(content)
[262] Fix | Delete
if need_convert
[263] Fix | Delete
rv << convert(value)
[264] Fix | Delete
else
[265] Fix | Delete
rv << value
[266] Fix | Delete
end
[267] Fix | Delete
rv << "</#{elem_name}>"
[268] Fix | Delete
rv
[269] Fix | Delete
else
[270] Fix | Delete
''
[271] Fix | Delete
end
[272] Fix | Delete
EOC
[273] Fix | Delete
end
[274] Fix | Delete
end
[275] Fix | Delete
[276] Fix | Delete
def install_date_element(tag_name, uri, occurs, name=nil, type=nil, disp_name=nil)
[277] Fix | Delete
name ||= tag_name
[278] Fix | Delete
type ||= :w3cdtf
[279] Fix | Delete
disp_name ||= name
[280] Fix | Delete
self::ELEMENTS << name
[281] Fix | Delete
add_need_initialize_variable(name)
[282] Fix | Delete
install_model(tag_name, uri, occurs, name)
[283] Fix | Delete
[284] Fix | Delete
# accessor
[285] Fix | Delete
convert_attr_reader name
[286] Fix | Delete
date_writer(name, type, disp_name)
[287] Fix | Delete
[288] Fix | Delete
install_element(name) do |n, elem_name|
[289] Fix | Delete
<<-EOC
[290] Fix | Delete
if @#{n}
[291] Fix | Delete
rv = "\#{indent}<#{elem_name}>"
[292] Fix | Delete
value = html_escape(@#{n}.#{type})
[293] Fix | Delete
if need_convert
[294] Fix | Delete
rv << convert(value)
[295] Fix | Delete
else
[296] Fix | Delete
rv << value
[297] Fix | Delete
end
[298] Fix | Delete
rv << "</#{elem_name}>"
[299] Fix | Delete
rv
[300] Fix | Delete
else
[301] Fix | Delete
''
[302] Fix | Delete
end
[303] Fix | Delete
EOC
[304] Fix | Delete
end
[305] Fix | Delete
[306] Fix | Delete
end
[307] Fix | Delete
[308] Fix | Delete
private
[309] Fix | Delete
def install_element(name, postfix="")
[310] Fix | Delete
elem_name = name.sub('_', ':')
[311] Fix | Delete
method_name = "#{name}_element#{postfix}"
[312] Fix | Delete
add_to_element_method(method_name)
[313] Fix | Delete
module_eval(<<-EOC, *get_file_and_line_from_caller(2))
[314] Fix | Delete
def #{method_name}(need_convert=true, indent='')
[315] Fix | Delete
#{yield(name, elem_name)}
[316] Fix | Delete
end
[317] Fix | Delete
private :#{method_name}
[318] Fix | Delete
EOC
[319] Fix | Delete
end
[320] Fix | Delete
[321] Fix | Delete
def inherit_convert_attr_reader(*attrs)
[322] Fix | Delete
attrs.each do |attr|
[323] Fix | Delete
module_eval(<<-EOC, *get_file_and_line_from_caller(2))
[324] Fix | Delete
def #{attr}_without_inherit
[325] Fix | Delete
convert(@#{attr})
[326] Fix | Delete
end
[327] Fix | Delete
[328] Fix | Delete
def #{attr}
[329] Fix | Delete
if @#{attr}
[330] Fix | Delete
#{attr}_without_inherit
[331] Fix | Delete
elsif @parent
[332] Fix | Delete
@parent.#{attr}
[333] Fix | Delete
else
[334] Fix | Delete
nil
[335] Fix | Delete
end
[336] Fix | Delete
end
[337] Fix | Delete
EOC
[338] Fix | Delete
end
[339] Fix | Delete
end
[340] Fix | Delete
[341] Fix | Delete
def uri_convert_attr_reader(*attrs)
[342] Fix | Delete
attrs.each do |attr|
[343] Fix | Delete
module_eval(<<-EOC, *get_file_and_line_from_caller(2))
[344] Fix | Delete
def #{attr}_without_base
[345] Fix | Delete
convert(@#{attr})
[346] Fix | Delete
end
[347] Fix | Delete
[348] Fix | Delete
def #{attr}
[349] Fix | Delete
value = #{attr}_without_base
[350] Fix | Delete
return nil if value.nil?
[351] Fix | Delete
if /\\A[a-z][a-z0-9+.\\-]*:/i =~ value
[352] Fix | Delete
value
[353] Fix | Delete
else
[354] Fix | Delete
"\#{base}\#{value}"
[355] Fix | Delete
end
[356] Fix | Delete
end
[357] Fix | Delete
EOC
[358] Fix | Delete
end
[359] Fix | Delete
end
[360] Fix | Delete
[361] Fix | Delete
def convert_attr_reader(*attrs)
[362] Fix | Delete
attrs.each do |attr|
[363] Fix | Delete
module_eval(<<-EOC, *get_file_and_line_from_caller(2))
[364] Fix | Delete
def #{attr}
[365] Fix | Delete
convert(@#{attr})
[366] Fix | Delete
end
[367] Fix | Delete
EOC
[368] Fix | Delete
end
[369] Fix | Delete
end
[370] Fix | Delete
[371] Fix | Delete
def explicit_clean_other_attr_reader(*attrs)
[372] Fix | Delete
attrs.each do |attr|
[373] Fix | Delete
module_eval(<<-EOC, __FILE__, __LINE__ + 1)
[374] Fix | Delete
attr_reader(:#{attr})
[375] Fix | Delete
def #{attr}?
[376] Fix | Delete
ExplicitCleanOther.parse(@#{attr})
[377] Fix | Delete
end
[378] Fix | Delete
EOC
[379] Fix | Delete
end
[380] Fix | Delete
end
[381] Fix | Delete
[382] Fix | Delete
def yes_other_attr_reader(*attrs)
[383] Fix | Delete
attrs.each do |attr|
[384] Fix | Delete
module_eval(<<-EOC, __FILE__, __LINE__ + 1)
[385] Fix | Delete
attr_reader(:#{attr})
[386] Fix | Delete
def #{attr}?
[387] Fix | Delete
Utils::YesOther.parse(@#{attr})
[388] Fix | Delete
end
[389] Fix | Delete
EOC
[390] Fix | Delete
end
[391] Fix | Delete
end
[392] Fix | Delete
[393] Fix | Delete
def csv_attr_reader(*attrs)
[394] Fix | Delete
separator = nil
[395] Fix | Delete
if attrs.last.is_a?(Hash)
[396] Fix | Delete
options = attrs.pop
[397] Fix | Delete
separator = options[:separator]
[398] Fix | Delete
end
[399] Fix | Delete
separator ||= ", "
[400] Fix | Delete
attrs.each do |attr|
[401] Fix | Delete
module_eval(<<-EOC, __FILE__, __LINE__ + 1)
[402] Fix | Delete
attr_reader(:#{attr})
[403] Fix | Delete
def #{attr}_content
[404] Fix | Delete
if @#{attr}.nil?
[405] Fix | Delete
@#{attr}
[406] Fix | Delete
else
[407] Fix | Delete
@#{attr}.join(#{separator.dump})
[408] Fix | Delete
end
[409] Fix | Delete
end
[410] Fix | Delete
EOC
[411] Fix | Delete
end
[412] Fix | Delete
end
[413] Fix | Delete
[414] Fix | Delete
def date_writer(name, type, disp_name=name)
[415] Fix | Delete
module_eval(<<-EOC, *get_file_and_line_from_caller(2))
[416] Fix | Delete
def #{name}=(new_value)
[417] Fix | Delete
if new_value.nil?
[418] Fix | Delete
@#{name} = new_value
[419] Fix | Delete
elsif new_value.kind_of?(Time)
[420] Fix | Delete
@#{name} = new_value.dup
[421] Fix | Delete
else
[422] Fix | Delete
if @do_validate
[423] Fix | Delete
begin
[424] Fix | Delete
@#{name} = Time.__send__('#{type}', new_value)
[425] Fix | Delete
rescue ArgumentError
[426] Fix | Delete
raise NotAvailableValueError.new('#{disp_name}', new_value)
[427] Fix | Delete
end
[428] Fix | Delete
else
[429] Fix | Delete
@#{name} = nil
[430] Fix | Delete
if /\\A\\s*\\z/ !~ new_value.to_s
[431] Fix | Delete
begin
[432] Fix | Delete
unless Date._parse(new_value, false).empty?
[433] Fix | Delete
@#{name} = Time.parse(new_value)
[434] Fix | Delete
end
[435] Fix | Delete
rescue ArgumentError
[436] Fix | Delete
end
[437] Fix | Delete
end
[438] Fix | Delete
end
[439] Fix | Delete
end
[440] Fix | Delete
[441] Fix | Delete
# Is it need?
[442] Fix | Delete
if @#{name}
[443] Fix | Delete
class << @#{name}
[444] Fix | Delete
undef_method(:to_s)
[445] Fix | Delete
alias_method(:to_s, :#{type})
[446] Fix | Delete
end
[447] Fix | Delete
end
[448] Fix | Delete
[449] Fix | Delete
end
[450] Fix | Delete
EOC
[451] Fix | Delete
end
[452] Fix | Delete
[453] Fix | Delete
def integer_writer(name, disp_name=name)
[454] Fix | Delete
module_eval(<<-EOC, *get_file_and_line_from_caller(2))
[455] Fix | Delete
def #{name}=(new_value)
[456] Fix | Delete
if new_value.nil?
[457] Fix | Delete
@#{name} = new_value
[458] Fix | Delete
else
[459] Fix | Delete
if @do_validate
[460] Fix | Delete
begin
[461] Fix | Delete
@#{name} = Integer(new_value)
[462] Fix | Delete
rescue ArgumentError
[463] Fix | Delete
raise NotAvailableValueError.new('#{disp_name}', new_value)
[464] Fix | Delete
end
[465] Fix | Delete
else
[466] Fix | Delete
@#{name} = new_value.to_i
[467] Fix | Delete
end
[468] Fix | Delete
end
[469] Fix | Delete
end
[470] Fix | Delete
EOC
[471] Fix | Delete
end
[472] Fix | Delete
[473] Fix | Delete
def positive_integer_writer(name, disp_name=name)
[474] Fix | Delete
module_eval(<<-EOC, *get_file_and_line_from_caller(2))
[475] Fix | Delete
def #{name}=(new_value)
[476] Fix | Delete
if new_value.nil?
[477] Fix | Delete
@#{name} = new_value
[478] Fix | Delete
else
[479] Fix | Delete
if @do_validate
[480] Fix | Delete
begin
[481] Fix | Delete
tmp = Integer(new_value)
[482] Fix | Delete
raise ArgumentError if tmp <= 0
[483] Fix | Delete
@#{name} = tmp
[484] Fix | Delete
rescue ArgumentError
[485] Fix | Delete
raise NotAvailableValueError.new('#{disp_name}', new_value)
[486] Fix | Delete
end
[487] Fix | Delete
else
[488] Fix | Delete
@#{name} = new_value.to_i
[489] Fix | Delete
end
[490] Fix | Delete
end
[491] Fix | Delete
end
[492] Fix | Delete
EOC
[493] Fix | Delete
end
[494] Fix | Delete
[495] Fix | Delete
def boolean_writer(name, disp_name=name)
[496] Fix | Delete
module_eval(<<-EOC, *get_file_and_line_from_caller(2))
[497] Fix | Delete
def #{name}=(new_value)
[498] Fix | Delete
if new_value.nil?
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function