This is not completely finished.  I didn' t have time to work out all the frequencies properly.  Nevertheless, it shows how FS, FT and DFT can be applied to analagous situations.

We' ll define a function that is 1 on - h, h and zero otherwise.  The ultimate interval of the function will not be specified explicitly.  But when we call FourierSeries, we'll say the period is 2, which implicitly corresponds to an interval of -1,1.

box[x_,h_] = UnitStep[x+h/2] - UnitStep[x-h/2];
Plot[box[x,1],{x,-1,1}]

<<FourierSeries`

ncoef = 20
g[x_] = FourierTrigSeries[box[x,1],x,ncoef,FourierParameters->{1,1/2}]

Here is the approximation to the box function using the first terms of a truncated Fourier Series.

Plot[g[x],{x,-1,1}]

the coefficients of the Fourier Series tell us the "power" at each frequency.  The frequencies themselves come from the arguments of the Cosine functions.

ftab = Table[0,{n,ncoef+1}];
ftab[[1]] = FourierCosCoefficient[box[x,1],x,0,FourierParameters->{1,1/2}];
Table[ftab[[n+1]] =  FourierCosCoefficient[box[x,1],x,2n-1,FourierParameters->{1,1/2}],{n,1,ncoef}];
ftab
 frequencies = Table[0,{i,ncoef}];
frequencies[[1]] = 0;
Table[frequencies[[i]] = 2i-1,{i,2,ncoef}];
frequencies

data = Table[{frequencies[[i]],ftab[[i]]},{i,ncoef}];
ListPlot[data,Joined->True,PlotRange->All]

h[k_] = FourierTransform[box[x,1],x,k]

Plot[h[k],{k,0,39 π},PlotRange->All]

Discrete Fourier Transform

x = Table[0,{i,100}];
x[[45;;55]] = 12
y = Fourier[x];
ListPlot[x,Joined->True]
ListPlot[Abs[y[[1;;50]]],Joined->True,PlotRange->All]